XML and namespaces
Alan Kennedy
alanmk at hotmail.com
Wed Dec 7 11:16:41 EST 2005
[Alan Kennedy]
>>Don't confuse libxml2dom with libxml2.
[Paul Boddie]
> Well, quite, but perhaps you can explain what I'm doing wrong with this
> low-level version of the previously specified code:
Well, if your purpose is to make a point about minidom and DOM standards
compliance in relation to serialisation of namespaces, then what you're
doing wrong is to use a library that bears no relationship to the DOM to
make your point.
Think about it this way: Say you decide to create a new XML document
using a non-DOM library, such as the excellent ElementTree.
So you make a series of ElementTree-API-specific calls to create the
document, the elements, attributes, namespaces, etc, and then serialise
the whole thing.
And the end result is that you end up with a document that looks like this
"""
<?xml version="1.0" encoding="utf-8"?>
<href xmlns="DAV:"/>
"""
It is not possible to use that ElementTree code to make inferences on
how minidom should behave, because the syntax and semantics of the
minidom API calls and the ElementTree API calls are different.
Minidom is constrained to implement the precise semantics of the DOM
APIs, because it claims standards compliance.
ElementTree is free to do whatever it likes, e.g. be pythonic, because
it has no standard to conform to: it is designed solely according to the
experience and intuition of its author, who is free change it at any
stage if he feels like it.
s/ElementTree/libxml2/g
If I've completely missed your point and you were talking something else
entirely, please forgive me. I'd be happy to help with any questions if
I can.
--
alan kennedy
------------------------------------------------------
email alan: http://xhaus.com/contact/alan
More information about the Python-list
mailing list