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 7 April 2010 18:28, Liam R E Quin <liam@w3.org> wrote:
> On Wed, 2010-04-07 at 16:13 +0100, Andrew Welch wrote:
>> Unprefixed namespaced xml can be a pain, but prefixed xml is no problem at all.
> I think this very much depends on the environment. Every week I get
> asked, for example, how to match namespaced nodes in XPath 1.0 from PHP;
> the best answer there usually turns out to be things like
>    /*[name() = 'document']/*[name() = 'chapter']/*[name() = 'title']
> (the xPath implementation most widely used with php doesn't seem to have
> a local-name() function).

That's the "best answer"??  I usually see that when the person doesn't
realise the unprefixed elements are in a namespace and think that's
the only way to select the elements...

Also, should a dubious but apparently most widely used xpath
implementation in php affect the recommended best practice for
namespaces? :)

> Pretty much every day I encounter people banging their heads against a
> wall (or a sturdy person) asking why their XPath xpressions don't match;

Me too, and it's usually the above - unprefixed elements in a namespace.

> I also occasionally hear from people who abandonded XML processing and
> moved to using JSON or some other technology, or who abandoned XPath
> or XSLT or XQuery, and went back to using Java and the DOM API, because
> they couldn't figure it out.

Yep, me too again...

> So while I hear your concern about possible ambiguities down the line,
> I still think that for most people using XML, and in most situations,
> it's better to avoid namespaces. Frankly, you're better off following
> Tim and Micah's suggestion (which became part of Micah's "pragmatic
> namespaces" proposal) and using element names like
>    welch.j.andrew.chapter rather
> than namespace prefixes.

That's an alternative I guess, not sure you would necessarily be
better off with that... the lexical xml would be a bit of a mess...

> All this is not to say that namespaces have no use. But they are used
> much more often than they are needed, they are wanted less often still,
> and they are ineffective at solving many of the problems people often
> expect them to solve.
> If you put prefixes on all your elements in case someone wants them,
> the chances are every bit as high that someone else will need to take
> them all off again. There's no single future-proof answer for all
> environments.

What do you mean when you say "someone else will need to take them all
off again" ?

The choice seems to be:

a) If you use the proper tools to process the XML and the developers
doing the processing know a little about XML... If so then using a
namespace (with prefix) is a good idea


b) You process the XML with something like PHP, and the majority of
the developers think XML is just like HTML... it's just angle brackets
after all... they create it by concatenating strings and read it using
regexes.  If so, then you should avoid namespaces completely (and also
avoid entity refs, and numeric refs, and stick to ascii etc...)

Andrew Welch
Kernow: http://kernowforsaxon.sf.net/

[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