3 ms·
> My biggest gripe with XML is namespaces followed by XSLT. XSLT I agree. Namespaces I quite like, the 3 issues I have being: * I can't write namespaced docum
by masklinn 16y ago
> My biggest gripe with XML is namespaces followed by XSLT.
XSLT I agree.
Namespaces I quite like, the 3 issues I have being:
* I can't write namespaced documents in Clark's notation. Clark's notation rocks.
* Some XML tools/libraries/whatever manage not to understand namespaces correctly.
* It's backwards-compatible with non-namespace-aware parsers. This is what makes XML namespaces broken and lets people avoid understanding them.
They're not even hard to get, you just have to understand a namespaced name is a shortcut for a pair of (namespace-uri, local-name), and that a namespace is scoped to the node it's declared on. And you're set, you're done with namespaces.
But instead, you have numbskull who tell you ElementTree 1.2 is broken because it has a very good handling of namespaces but doesn't let you configure a default namespace or customize namespace aliases on serialization (it just sets them as ``ns\d``).
Oh yeah, now that I think about it there is one completely broken thing about XML namespaces (as far as I'm concerned): an element with no specified namespace lives in the current default namespace (``xmlns=uri``), but an attribute with no specified namespace lives min the "null" namespace instead. That is stupid and annoying.
- 8ren 16y agoNamespaces, as an abstract idea, are great. But I find XML's version confusing in practice. It's partly the several different ways of configuring defaults (four I think), and partly the syntax. You'd think they'd be as easy as Java: set-and-forget defaults (eg. java.util.*); or explicitly qualify everything (in import or in use). In practice, collisions are rare. Is it harder in XML because arbitrary XML documents are commonly nested? (which can't happen to Java source code)
- masklinn 16y ago> It's partly the several different ways of configuring defaults (four I think) Which ones? I only know of using the xmlns attribute to set a default namespace, though as I mention above (in my formatting-broken-by-HN text) attributes playing by completely different namespace rules is... annoying, to say the least. > Is it harder in XML because arbitrary XML documents are commonly nested? That's about the only difference, and I don't think it matters much, in my opinion (nor do I think Java's namespaces are very good). And XML namespaces are actually unique, unless you do very stupid things you can't have namespace collisions though you can have namespace-alias collisions (and as I noted above, using Clark's notation is a great way to understand how things actually work)