[
Lists Home |
Date Index |
Thread Index
]
Paul Prescod wrote:
> Joe English wrote:
> > In addition to writing XML documents, I also write software
> > that processes those XML documents. That's where the real
> > namespace pain begins.
>
> If you are writing software that _implements_ namespaces (e.g. a parser
> or filter or API) then I can see the problem. If you write software that
> _uses_ namespaces, I don't see it that much.
I do both.
No, wait, that's a lie: I do neither. I write programs that
process XML, and often end up writing toolkits to make writing
those programs easier, but to date I haven't implemented XMLNS
support in anything.
> Writing an XSLT for a
> document with namespaces is not much harder than writing it for one
> without.
That's *exactly* the level of sanity I'd like to see in a
general-purpose toolkit! With XSLT, you can declare all the
namespaces you're interested in in one place, write names as
atomic strings everywhere else (using your preferred prefixes),
and you never need to worry about in-scope namespace nodes,
namespace declarations, or decomposing or reserializing QNames,
since the processor takes care of all that for you. The only time
things get hairy is when the source document uses QNames-in-content.
> Ditto with Python.
Perhaps. The xml.dom module has separate "doFoo" and "doFooNS"
methods for most element and attribute-related operations;
that's a big strike against it in my book. What happens if you do:
someNode.appendChild(dom.createElementNS(someURI, someGI))
where 'someNode' has no in-scope namespace binding for 'someURI'?
(The documentation is unclear on this). Does it do something
reasonable, or do you end up with an invalid DOM?
> [...]
> Now I will happily admit that there are circumstances where namespaces
> are massively painful to code around. In particular, when you are
> implementing the infrastructure.
Maybe that's my problem: I like to build infrastructure.
SAX-like and DOM-like interfaces are way too low-level for
my tastes, so I'm always building higher-level abstractions
on top of them to match the task at hand. These are much
harder to get right when you have to worry about namespaces.
--Joe English
jenglish@flightlab.com
|