[Xml-compile] some kind of default schema for a REST XML interface

Mark Blackman m.blackman at fairfx.com
Tue Jun 29 20:58:52 GMT 2010


Hi,

I wondered if anyone would care to offer an advice on how to handle
an XML document that has no schema, but builds in type information.

I'm trying to build up a Perl module to interface to a REST API that is
XML-based. However, there is no schema for the XML output (from a Ruby-based
system).

It tends to typecast the elements via an element attribute (type) like so:

<?xml version="1.0" encoding="UTF-8"?>
<invoices type="array">
  <invoice>
    <id type="integer">85</id>
    <contact-id type="integer">10</contact-id>
    <project-id type="integer">16</project-id>
    <dated-on type="datetime">2008-02-17T00:00:00Z</dated-on>

I've applied a schema generator like Trang to an instance of
the output and gotten semi-reasonable results, although I dislike
the result where the actual value winds up in a hash reference like
$invoice->{dated_on}->{_} due to the treatment of the type attribute
as another key-value pair for the element.

However, I wonder if XML::Compile has any nice way of handling this
kind of XML where simple type information is already encoded in
the original XML instead of being delegated to an external schema.

- Mark





More information about the Xml-compile mailing list