[MTOS-dev] XML parsing

Byrne Reese byrne at sixapart.com
Thu Mar 6 21:30:12 PST 2008



On 3/5/08 9:53 AM, "Mark Paschal" <mark at sixapart.com> wrote:
> It would seem we could further use the same fallback technique we
> already use, eventually falling back to a pure-perl XML module such as
> XML::SAX::PurePerl. To keep developing MT and plugins simple, though,
> we would want to build a sort of "XML::Any" module that encapsulates
> the selection of an XML library and provides a common API. That's a
> non-trivial undertaking, so other solutions are welcome.

XML::Any would be a huge undertaking no doubt. But honestly, it would
perhaps be one of the most valuable contributions we could make to the Perl
developer community. And that I think is saying something.

XML is increasingly the preferred data format, surpassing not just all other
text formats, but binary formats as well. XML is such a foundational part of
the internet as well with every known API utilizing it in some way.

Think for a moment what it was like (if you can remember) or what it would
be like without DBI. Imagine having to remember a different API for every
database driver. Imagine how hard it would become for so many people to move
from Oracle to MySQL or vice versa. We take it for granted that such a move
is a relatively trivial one.

In fact, because a standard interface has been defined, solutions like
Data::ObjectDriver exist.

If we could do the same thing for XML as DBI did for databases, that would
be huge. Huge I tell you. Huge. :)

This is something the java folks figured out early on which I really
respect. The defined JAXP which provides a parser and platform agnostic API
for XML processing in Java. Once that was defined, then swapping out one XML
parser for another becomes trivial. Apps simply need to code to the standard
and administrators are free to develop their own parser and install their
preferred one.

So what would XML::Any look like?

Well DBI provides a good model I think:

* There is a base interface that provides virtually no functionality. It
simply defines the interface that other packages should implement. In two
forms of course: DOM and SAX based parsing.
* We would then want to work with the maintainers of other key XML parsers
in perl to implement that interface.
* In the interim we should implement compatibility packages that map the
funcitonality properly into the API: like XML::Parser::AnyCompat or
something to that effect.

I might also suggest we start by cloning the JAXP interface. It is a tried
and true specification and one that should map in theory to Perl.

But again - this is no small undertaking, but it would be insanely valuable
IMHO. I can only imagine how much simpler SOAP::Lite would become for
example if I could have coded it against a common XML Parser API. Holy moly.

Byrne



More information about the MTOS-dev mailing list