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


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: quick XPath question: finding /a/b/c with a default namespace

Hi David

Thanks for your answer. I first thought that was how it worked but the
following sentence in the XPath spec confused me:-

"the default namespace declared with xmlns is not used: if the QName does
not have a prefix, then the namespace URI is null"

So I thought that

<a xmlns="foo">

would have a namespace URI of null. Which would be the same namespace URI of


FWIW I'm not using XPath from inside XSLT, I'm using it on a dom4j object
model. So its much less convenient to define a namespace context.

So in non-XSLT uses, without explicitly creating a namespace context and
populating it with xmlns:x="dummyNamespace" up front and then using the path
/x:a/x:b/x:c I can only find <c> with the XPath expression


This seems unfortunate for non-XSLT uses of XPath.


----- Original Message -----
From: "David Carlisle" <davidc@nag.co.uk>
To: <james_strachan@yahoo.co.uk>
Cc: <xml-dev@lists.xml.org>
Sent: Friday, July 27, 2001 10:45 AM
Subject: Re: quick XPath question: finding /a/b/c with a default namespace

> > (Strictly speaking maybe
> > XPath questions should be sent to the XSL mail list?)
> (probably, and this answer will be in the FAQ for that list)
> > Should the path ..find the <c> element?
> No. For the reason you give, the default namespace is not used in the
> Xpath. But you misunderstand the meaning of
> > <a xmlns="dummyNamespace">
> > So the default namespace is not used and none of the QNames in the
> > or the path have namespace prefixes, so the namespace URI is null for
> > the QNames.
> whether or not a prefix is used has no effect on the namepace URI.
> The namespace URI on all of the elements a  b  and c in your example is
> dummyNamespace, so the Xpath you require is
> x:a/x:b/x:c
> where x: is the prefix assigned to the namepace URI dummyNamespace in
> the stylesheet.
> David
> _____________________________________________________________________
> This message has been checked for all known viruses by Star Internet
> delivered through the MessageLabs Virus Scanning Service. For further
> information visit http://www.star.net.uk/stats.asp or alternatively call
> Star Internet for details on the Virus Scanning Service.


Do You Yahoo!?

Get your free @yahoo.com address at http://mail.yahoo.com