[Xml-compile] Fwd: XML::LibXML::Simple nil and restructuring

Joshua Keroes joshua at keroes.com
Tue Jun 18 16:13:01 GMT 2013


I'm looking for help whittling down XML processing options. Right now I see
too many ways to do things and each implementation will take time.

I'm proxying requests to an unhelpful API, trying to make lookups easier
(done), simplify their XML (done with XML::LibXML::Simple and Data::Visitor
but slow), and returning the response to the user.

There are two things I'm simplifying in this XML snippet:

*      <rows>*
*          <r>*
*              <properties>*
*                  <property name=3D"healthIndex" type=3D"int">0</property>*
*              </properties>*
*              <cellproperties/>*
*              <c xmlns:xsi=3D"http://www.w3.org/2001/XMLSchema-instance"
xsi:nil=3D"true"/>*
*              <c xmlns:xsi=3D"http://www.w3.org/2001/XMLSchema-instance"
xsi:nil=3D"true"/>*
*              <c xmlns:xsi=3D"http://www.w3.org/2001/XMLSchema-instance"
xsi:nil=3D"true"/>*
*          </r>*
*      </rows>*

With options *keyattr =3D> [qw/ name description /], forcearray =3D> [qw/ r=
ows
r c /]*, X::L::S converts that to:

*  'rows' =3D> [*
*        {*
*          'r' =3D> [*
*            {*
*              'c' =3D> [*
*                {*
*                  'xsi:nil' =3D> 'true',*
*                  'xmlns:xsi' =3D> 'http://www.w3.org/2001/XMLSchema-insta=
nce
'*
*                },*
*                {*
*                  'xsi:nil' =3D> 'true',*
*                  'xmlns:xsi' =3D> 'http://www.w3.org/2001/XMLSchema-insta=
nce
'*
*                },*
*                {*
*                  'xmlns:xsi' =3D> 'http://www.w3.org/2001/XMLSchema-insta=
nce
',*
*                  'xsi:nil' =3D> 'true'*
*                }*
*              ],*
*              'properties' =3D> {*
*                'property' =3D> {*
*                  'type' =3D> 'int',*
*                  'content' =3D> '0',*
*                  'name' =3D> 'healthIndex'*
*                }*
*              },*
*              'cellproperties' =3D> {}*
*            }*
*          ]*
*        }*
*      ]*

Thing 1: I would like to see *undef* instead of* { 'xsi:nil' ... }* blocks.
e.g. *c =3D> [ undef, undef, undef ] . *I have a Data::Visitor solution that
can do this but it's slow.

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 =3D> [*
*      [ undef, undef, undef ],*
*    ]*
*
*
And for responses with more complex data:

*    rows =3D> [*
*      [ 1.0, 2.2, 4.1 ],*
*      [ 1.0, 2.1, 4.0 ],*
*      [ 1.0, 2.2, 4.1 ],*
*    ]*
*
*
Before I spend a few days writing the code to reimplement these with LibXML
or LibXSLT, I was wondering if there was a better, faster, or smarter way.

Thanks all,
Joshua
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/xml-compile/attachments/20130618/05=
97e5c2/attachment.htm


More information about the Xml-compile mailing list