Re: Is a namespace [always] a [shared] resource?

>If I go (as I have)
>
>xmlns:x="x"
>xmlns:y="y"
>xmlns:z="z"

Question: What do you really gain by doing so? You do save a few bytes and
keystrokes in a string that typically appears once and only once in the
file, but I'm afraid that I don't consider that an extremely compelling
argument.

And how often are you really going to want to do this? Generally,
namespaces are more than just disambiguation; they're strings that
application code matches on, and that application layer is going to drive
what names are meaningful. For example, if you're writing an XSLT
stylesheet, you have to use XSLT's namespace. Even if all you're doing is
validating against a schema, I think you're going to find that most schemas
_do_ want their names to be global.

Also, if you don't care about the NS per se and just want to prefix your
names -- what's the advantage of using namespaces at all? Why not replace
your
     <x:foo xmlns:x="x"/>
with
     <x-foo/>
which is even more compact and virtually identical in effect? Namespaces
have an advantage over concatenating to the name only when what's being
concatentated is relatively large, or not in XML name syntax, or carries
implications of globalness -- in other words, when the namespace's identity
is expressed as a URI or something similar. If your intent is not to place
the names in a namespace, don't abuse the namespace syntax.

Finally, as the past month's debate has proven, using relative names does
not communicate well with humans attempting to read your document; there
are too darned many possible ways of interpreting this.



I understand what you're trying to do; I've been tempted to do it myself
when just "hacking around" with namespaced documents, for the same reasons
that I've sometimes sloppily used a relative URIRef to point to my DTDs.
But I think I've convinced myself that in the case of namespaces it's
definitely a bad practice.


>David is not the only Unix speaker who will use /dev/null as a "random
string"

People can still do so. They just have to make their intent explicit by
saying "file:/dev/null".


>For locally-defined XSL extensions, local names are appropriate and
>XML-global names are not.

Not so, actually. If you use purely local names, then someone else may use
the same name for a different purpose, and when you share your stylesheets
with them the error will be undetectable and the result will be
unpredictable. We can't prevent all such mistakes, but we can greatly
increase our odds of catching them before they damage data.



I'm afraid that I'm having trouble finding a way in which the requirement
that namespaces be declared as absolute will really cause trouble. If
you've got a real-world example that can't be trivially solved by just
prefixing it with "file:/" or "ns:/" or something of that sort, please
post.

Received on Friday, 9 June 2000 08:50:01 UTC