[prev] [thread] [next] [Date index for 2006/02/01]
--===============0402174914==
Content-Type: multipart/alternative;
boundary="----=_Part_5717_25872284.1138822098579"
------=_Part_5717_25872284.1138822098579
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline
Hello Gentlemen,
Hope this is the proper place to discuss Class::DBI::ToSax. I have devised =
a
small patch to allow me to select which columns, and in which order, I will
have SAX events generated for. Seems to work for me. Would love to have
someone knowledgeable to tell me if this is of some public value.
Works by optionally giving your object a to_sax_columns method which return=
s
a reference to a list with desired columns and order. Should keep former
ToSax behavior if not defined.
Thank you in advance.
[oso@osobox xml]$ diff ToSax.pm ToSax.pm.orig
86,112c86,97
< if( $self->can( 'to_sax_columns' ) ) {
< my %has_many =3D map { $_ =3D> 1 } @{ $self->_has_many_me=
thods
|| [] };
< foreach my $col ( @{ $self->to_sax_columns } ) {
< if( defined $has_a{ $col } ) {
< $self->_emit_sax_value( $handler, $col,
$self->$col, %opt,
< wrapper =3D> $col );
< } elsif ( defined $has_many{ $col } ) {
< $self->_emit_sax_value( $handler,
$col, $_, %opt )
< foreach $self->$col;
< } else { # plain
< $self->_emit_sax_value( $handler, $col,
$self->$col, %opt );
< }
< }
< } else {
< foreach my $col ( sort @plain ) {
< $self->_emit_sax_value( $handler, $col, $self->$col, %opt
);
< }
<
< foreach my $col ( sort keys %has_a ) {
< $self->_emit_sax_value( $handler, $col, $self->$col, %opt=
,
< wrapper =3D> $col );
< }
<
< foreach my $col ( sort @{ $self->_has_many_methods || [] } ) =
{
< $self->_emit_sax_value( $handler, $col, $_, %opt )
< foreach $self->$col;
< }
---
> foreach my $col ( sort @plain ) {
> $self->_emit_sax_value( $handler, $col, $self->$col, %opt );
> }
>
> foreach my $col ( sort keys %has_a ) {
> $self->_emit_sax_value( $handler, $col, $self->$col, %opt,
> wrapper =3D> $col );
> }
>
> foreach my $col ( sort @{ $self->_has_many_methods || [] } ) {
> $self->_emit_sax_value( $handler, $col, $_, %opt )
> foreach $self->$col;
--
Eduardo Grosclaude
Universidad Nacional del Comahue
Neuquen, Argentina
------=_Part_5717_25872284.1138822098579
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline
Hello Gentlemen,<br>Hope this is the proper place to discuss Class::DBI::To=
Sax. I have devised a small patch to allow me to select which columns, and =
in which order, I will have SAX events generated for. Seems to work for me.=
Would love to have someone knowledgeable to tell me if this is of some pub=
lic value.
<br>Works by optionally giving your object a to_sax_columns method which re=
turns a reference to a list with desired columns and order. Should keep for=
mer ToSax behavior if not defined.<br>Thank you in advance.<br><br clear=3D=
"all">
[oso@osobox xml]$ diff ToSax.pm ToSax.pm.orig<br>86,112c86,97<br>< =
if( $self->can( 'to_sax_colum=
ns' ) ) {<br>< &nbs=
p; my %has_many =3D map { $_ =3D> 1 =
} @{ $self->_has_many_methods || [] };<br>
<  =
; foreach my $col ( @{ $self->to_sax_columns } )=
{<br><  =
; &n=
bsp; if( defined $has_a{ $col } ) {<br>< &n=
bsp;  =
; $self->_em=
it_sax_value( $handler, $col, $self->$col, %opt,
<br>< &=
nbsp; &nbs=
p; wrapper =3D> $col );<=
br>< &n=
bsp;  =
; } elsif ( defined $has_many{ $col } ) {<br>< &n=
bsp;  =
; &n=
bsp; $self->_emit_sax_value( $handle=
r, $col, $_, %opt )
<br>< &=
nbsp; &nbs=
p; &=
nbsp; foreach $self->$col;<br>< &n=
bsp;  =
; } else { # plain<br><&=
nbsp; &nbs=
p; &=
nbsp; $self->_emit_sax_value( $handler, $col, $self->$col=
, %opt );
<br>< &=
nbsp; &nbs=
p; }<br>< &nb=
sp; }<br>< &n=
bsp; } else {<br>< =
foreach my $col ( sort @plain ) {<br><&nb=
sp; =
$self->_emit_sax_value( $handler, $col, $self->$co=
l, %opt );
<br>< &=
nbsp; }<br><<br>< &nbs=
p; foreach my $col ( sort keys %has_a ) {<br>< &n=
bsp;  =
; $self->_emit_sax_value( $handler, $col, $self->$col, %o=
pt,<br>< &nbs=
p; wrapper =3D> $c=
ol );
<br>< &=
nbsp; }<br><<br>< &nbs=
p; foreach my $col ( sort @{ $self->_has_many_methods =
|| [] } ) {<br>< &n=
bsp; $self->_emit_sax_value( $handle=
r, $col, $_, %opt )<br>< =
fo=
reach $self->$col;
<br>< &=
nbsp; }<br>---<br>> fore=
ach my $col ( sort @plain ) {<br>> &n=
bsp; $self->_emit_sax_value( $handler, $co=
l, $self->$col, %opt );<br>>  =
; }<br>><br>> f=
oreach my $col ( sort keys %has_a ) {
<br>> &=
nbsp; $self->_emit_sax_value( $handler, $col, $self->$col, %opt,<br>&=
gt; =
wrapper =3D> $col );<br>> &=
nbsp; }<br>><br>> &nbs=
p; foreach my $col ( sort @{ $self->_has_many_methods =
|| [] } ) {
<br>> &=
nbsp; $self->_emit_sax_value( $handler, $col, $_, %opt )<br>> &n=
bsp;  =
; foreach $self->$col;<br><br>-- <br>Eduardo Grosclaude<br>U=
niversidad Nacional del Comahue<br>Neuquen, Argentina
------=_Part_5717_25872284.1138822098579--
--===============0402174914==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
ClassDBI mailing list
ClassDBI@xxxxx.xxxxxxxxxxxxxxxx.xxx
http://lists.digitalcraftsmen.net/mailman/listinfo/classdbi
--===============0402174914==--
|
[CDBI] Adding behavior to Class::DBI::ToSax
|
Generated at 17:59 on 03 Feb 2006 by mariachi v0.52