The XML::Compile list?
On Tue, Jun 18, 2013 at 12:46 AM, Mark Overmeer <[email protected]> wrote: > > Hi Joshua, > > Please post to the list. > > * Joshua Keroes ([email protected]) [130617 23:15]: > > I'm proxying requests to an unhelpful API, trying to make lookups easier > > (done), and trying to "fix" their XML (done with XML::LibXML::Simple and > > Data::Visitor but slow), and returning the response to the user. > > > With options *keyattr => [qw/ name description /], forcearray => [qw/ > rows > > r c /]*, X::L::S converts that to: > > > > * 'rows' => [* > > * {* > > * 'r' => [* > > * {* > > * 'c' => [* > > * {* > > * 'xsi:nil' => 'true',* > > * 'xmlns:xsi' => ' > http://www.w3.org/2001/XMLSchema-instance > > '* > > * },* > ... > > * ],* > > * 'properties' => {* > > * 'property' => {* > > * 'type' => 'int',* > > * 'content' => '0',* > > * 'name' => 'healthIndex'* > > * }* > > * },* > > * 'cellproperties' => {}* > > * }* > > * ]* > > * }* > > * ]* > > > > Thing 1: I would like to see *undef* instead of* { 'xsi:nil' ... }* > blocks. > > e.g. *c => [ undef, undef, undef ] . *I have a Data::Visitor solution > that > > can do this but it's slow. > > XML::LibXML::Simple is just a reimplementation of the XML::Simple > interface using the XML::LibXML parser. It is not more clever. > > > Thing 2: *r* and *c* are just arrays. They don't need to be named arrays. > > Did I miss a way to eat those keys? In other words, what I'd like to see > is: > > > > * rows => [* > > * [ undef, undef, undef ],* > > * ]* > > * > > And for responses with more complex data: > > > > * rows => [* > > * [ 1.0, 2.2, 4.1 ],* > > * [ 1.0, 2.1, 4.0 ],* > > * [ 1.0, 2.2, 4.1 ],* > > * ]* > > When the data structure is so well known, it is easy to avoid the use > of Data::Visitor. Something like this (untested) > > my $rows = .... > my @r; > foreach my $r (@{$rows->[0]{r}}) > { my @c; > foreach my $c (@{$r->[0]{c}}) > { push @c, ref $c eq 'HASH' && $c->{'xsi:nil'} ? undef : $c; > } > push @r, \@c; > } > \@r; > > Not more complex than this. (You loose the 'properties' info') > -- > Regards, > MarkOv > > ------------------------------------------------------------------------ > Mark Overmeer MSc MARKOV Solutions > [email protected] [email protected] > http://Mark.Overmeer.net http://solutions.overmeer.net > >
_______________________________________________ Xml-compile mailing list [email protected] http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/xml-compile
