Having just released the first available version (v0.52) of
XML::Pastor, I have found this discussion list that might best suit
speaking about it.
Let me run the commercial....
Now you don't need to write code in an ugly language like Java in
order to be able to get native XML support. Because now, there is
XML::Pastor is a revolutionary new way to handle XML documents in Perl.
Give it a try. You won't regret it. Guaranteed (or almost).
In fact, if you are familiar with Java's XML CASTOR, this module
(XML::Pastor) will be very familiar to you. XML::Pastor is very
similar to Java's Castor, however, as usual with Perl, it's more
flexible. On the other hand, full XSD support is not achieved yet (a
lot is already supported, see below).
XML::Pastor will actually generate Perl code starting with one or more
W3C Schema(s) (XSD). The generated code is as easy, if not easier, to
use as XML::Simple. YET (and this is the tricky part), you can also
easily read and write to and from an XML document ('instance' of the
schema) abiding by the rules of the schema. You can even validate
against the original schema before writing the XML document.
However, you don't need the original schema at run-time (unless you
are doing run-time code generation). Everything is translated into
Perl at code generation time. Your generated classes 'know' about how
to read, write, and validate XML data against the rules of the
original schema without the actual schema at hand.
Attributes and child elements can be accessed through auto-generated
accessors or hash items. You don't need to know or worry about whether
or not a child element appears once or multiple times in the XML
document. This is automagically taken care of for you. If you access
the child element as an array (with a subscript), it is OK. But you
don't need to. You might as well access the first such element
directly, without needing to know that there are others.
Code can be generated at 'make' time onto disk (the so-called
'offline' mode) or it can be generated and 'eval'ed for you as a big
chunk at run-time. Or you can get it as a string ready to be evaled.
In 'offline' mode, you can choose to use a 'single' module style
(where all code is in one big chunk), or in 'multiple' style, where
each class is written to dik in a separate module.
There is also a command line utility, called 'pastorize' that helps
you do this from within 'make' files.
Gone with the multiplicity problem of XML::Simple. Gone with the
complexity of dealing with XML as XML. Now you can deal with XML data
as real Perl objects (with accessors for child elements and
attributes). But you can still get XML back out of it at the end of
W3C SCHEMA SUPPORT
Most of the W3C XSD Schema structures are supported. Notable exception
is substitution sets. Namespace support is currently a bit shaky (at
most one namespace per generation). That's why schema 'import' is not -
yet- supported. However, schema 'include' and 'replace' are supported.
All W3C schema builtin types have Perl counterparts with validation.
This includes datetime and date types as well (You can get/set these
with CPAN's DateTime objects as well).
Internally, XML::Pastor uses XML::LibXML to deal with actuial xml
reading/writing XML (but not for validation). But, you don't need to know anything about XML::LibXML for being able to use XML::Pastor.
Give it a try please. And enjoy...
Note: It's already on CPAN. Just search for XML::Pastor on search.cpan.org.