OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
Re: [xml-dev] To namespace or not to Namespace ....

On Thu, 2010-04-08 at 15:19 -0700, Kendall Shaw wrote:

> The question is similar to whether or not to use namespaces in java or
> c++, it seems to me.
This is actually somewhat dangerous reasoning, although seductive.
Namespaces in XML do not in fact work like namespaces in C++ or Java.


> Namespaces cause problems for people doing text processing instead of
> XML processing,
Actually they cause problems for people doing XML processing too. The
most frequently asked questions on XML support forums and channels are
about problems processing namespaces.

> If, instead, you turn this into a principal that you should make your
> use of XML suitable to people who have taken an oath to never understand
> XML and continue with text processing (i.e. don't use namespaces just so
> that people involved can continue to think of XML as text files with
> pointy brackets), it will cause problems. Or, that has been my
> experience.

Well, I don't recommend that either, we can agree on that point. XML was
deliberately designed so that it can be processed as text, if you are
careful. Of course, people are rarely careful enough, and forget about
CDATA sections and comments, and then end up photographing their own

However, namespaces in C++ or Perl or Python or Java have a behavioural
semantic that is absent for XML namespaces. In XML, the idea of
importing a set of names to use is geerally done with a schema of some
kind (DTD, XSD, RNG, Schematron, etc), so that you can check that you
are in fact using the imported names correctly. This is actually
orthogonal to namespaces in XML; the namespace prefix is needed in
order to disambiguate, e.g. if two different vocabularies have an "a"
element, one for Author and one for Anchor, and both could occur in
the same context.

The price you pay, though, is high. It's as if, once you used the Math
namespace in Java, you could no longer write arithmetic expressions with
    a = b + c;
but now had to use
    math.assign(a, math.sum(math.numericvalue(b), math.numericvalue(c));

You can't write, for example, /html/head/meta[@name eq 'link'] but,
instead, /h:html/h:head/h:meta[@name eq 'link'], and you have to
understand why (and when) it's @name and not @h:name. So this isn't
anything to do with processing XML as text.

All of this is not to say that namespaces have no use. It's to say that
the usefulness comes at a higher cost than many people seem to consider,
and that the cost isn't directly comparable to the cost of using
namespaces in programming languages.



Liam Quin - XML Activity Lead, W3C, http://www.w3.org/People/Quin/
Pictures from old books: http://fromoldbooks.org/
Ankh: irc.sorcery.net irc.gnome.org www.advogato.org

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS