[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: To namespace or not to Namespace ....

  • From: Liam R E Quin <liam@w3.org>
  • To: Kendall Shaw <kshaw@kendallshaw.com>
  • Date: Thu, 08 Apr 2010 20:07:13 -0400

Re:  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
feet.

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.

Best,

Liam

-- 
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]


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.