Skip Menu |
 

This queue is for tickets about the XML-Generator-DBI CPAN distribution.

Report information
The Basics
Id: 4978
Status: new
Priority: 0/
Queue: XML-Generator-DBI

People
Owner: Nobody in particular
Requestors: jason [...] pollock.ca
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 1.00
Fixed in: (no value)



Subject: Combine rows as elements/attributes.
Download (untitled) / with headers
text/plain 417b
Great tool. It's working wonders for me. :) I was wondering if it is possible to extend the heirarchical grouping (x/y) in column names to include attributes as well? I've added support for this for the RowElement (@id generates <rowelement id="">), but to be complete it would need to be passed down the entire stack (x/@y). I haven't needed that feature yet, so I haven't gotten to it. :) Thanks, Jason Pollock
Download DBI.patch
text/x-diff 1.9k
Index: cpan/XML/Generator/DBI.pm diff -u cpan/XML/Generator/DBI.pm:1.2 cpan/XML/Generator/DBI.pm:1.3 --- cpan/XML/Generator/DBI.pm:1.2 Mon Dec 8 13:29:18 2003 +++ cpan/XML/Generator/DBI.pm Tue Jan 20 14:23:47 2004 @@ -1,4 +1,4 @@ -# $Id: DBI.pm,v 1.2 2003/12/08 00:29:18 jpollock Exp $ +# $Id: DBI.pm,v 1.3 2004/01/20 01:23:47 jpollock Exp $ package XML::Generator::DBI; use strict; @@ -110,6 +110,7 @@ # output columns if necessary $proxy->add_column_info($sth, $names); + # Row is actually the set of individual columns in the row. my @row; $sth->bind_columns( \( @row[ 0 .. $#{$names} ] ) @@ -150,7 +151,27 @@ $proxy->send_group($row, $group, $group_by_ind); - $proxy->send_start($proxy->{RowElement}) if $proxy->{RowElement}; + # O.k. anything that's preceeded by an @ is an allowed attribute. + # Not doing this for stacked elements. + my %attribs = map { $names->[$_] => $row->[$_] } # create hash + grep { defined $row->[$_] } # remove undef ones + grep { $names->[$_] ne $proxy->{GroupBy} } #remove group data + grep { $names->[$_] =~ /^@/ } # ensure that the name starts with @ + (0 .. $#{$names}); + + # The only attributes here should be the @'ed ones... + foreach my $i (keys(%attribs)) { + my $key = $i; + $key =~ s/^@//; + + # Store it into the temporary, so that we don't have to worry about it + # Really being an @'ed attribute. + my $value = $attribs{$i}; + delete $attribs{$i}; + $attribs{$key} = $value; + } + + $proxy->send_start($proxy->{RowElement}, %attribs) if $proxy->{RowElement}; my @stack; my @el_stack; @@ -160,6 +181,11 @@ # skip group element if ((! defined $row->[$i]) && ($proxy->{ShowNull})) { $row->[$i] = ""; + } + + # Skip the attributes. + if ($names->[$i] =~ /^@/) { + next; } if (defined($proxy->{GroupBy}) and $i == $group_by_ind){


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.