XML overuse? (was Re: Python to XML to Python conversion)

François Pinard pinard at iro.umontreal.ca
Sat Jul 13 09:50:06 EDT 2002


[Jonathan Hogg]

> To summarise the advantages of using XML as I see them:

>  * Standardised parsing  (PyXML etc.)
>  * Standardised validation  (DTDs, XSchema)
>  * Standardised editing  (XML-aware editors)
>  * Standardised querying  (XPath, XQuery)
>  * Standardised transformation  (XSLT)
>  * Standardised storage  (XML:DB)

This is no more advantage being `XML-standardised' for the only sake of
being `XML-standardised' than going `XML' for the only sake of going `XML'.
In the table above, `standardised' like a buzzword.  As a Python lover,
I'm tempted to replace `standardised' by `easy' and `legible' wherever I can.

For simple system tables, like the one that was given as example previously
in this thread, I quite doubt the Linux kernel will soon go to the lengths
of XML parsing, querying, and database storage.

> I really am willing to eat humble pie here and admit that I'm mistaken if
> someone can give me a similar list of good reasons to *not* use XML for
> off-line hierarchically structured data.

Any file is a hierarchy of some sort.  We often see a file being a sequence
of lines, a line being a sequence of fields or tokens, and tokens being
a sequence of characters.  In many, many, really many applications, this
organisation in lines and fields is wholly satisfactory.  Reusing the
enumeration above, it is easy to parse, easy to validate, easy to edit, easy
to query, easy to transform and easy to store.  Let's be honest.  People are
comfortable with lines and fields, examples and tools merely _abound_.

XML becomes more sensible when you have a _lot_ of structure, something which
is complex, difficult, and which you have to exchange with away parties.
For simple things, it is just annoying and heavy overkill, really...

Speaking for my own situation only, as a Python lover, XML is gross overkill
even for quite complex things.  It is extremely simple to pickle rather
complex structures, transmit them over wires to applications on other
machines, and unpickle them there.  Using Python as an API for such usages
is natural and very comfortable, and not to say, immensely faster than XML.

Of course, I would prefer XML is I had to speak outside a Python environment,
with people offering nothing simpler than an XML interfaces.  I've looked
into some of these fashioned avenues.  So far, they invariably seem extremely
complex and hairy to me, at least for what they provide.  XML is there to
give users a reinsurance on the fact they have a last-resort control, after
all, to inspect what is going on, or to intervene if they ever need to.  So,
for them, I really understand how valuable XML may be.  It's a good thing.

In my simple situations, Python is much, much better than XML as a solution.
Moreover, Python offers me a good set of XML tools and interfaces if I have
no choice than communicate with an outside world groking XML!  For one,
when I really need a marking language for my users, without having XML
imposed from the outside, SGML is often a better solution, as it is closer
to humans than XML.  There might also be better solutions than SGML, too.
XML is mainly there to help implementors.  Surely, I like humans far more
than I like machines, and this feeling mainly drives my efforts. :-)

> Perhaps I'm missing something blindingly obvious here, but what benefits
> would I gain from coming up with my own format?

For simple things?  Ease, speed, simplicity, readability.  Don't fear it.
The world will survive, you know, even if you sometimes don't use XML. :-)

-- 
François Pinard   http://www.iro.umontreal.ca/~pinard





More information about the Python-list mailing list