[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: quick XPath question: finding /a/b/c with a default namespace
- From: James Strachan <email@example.com>
- To: David Carlisle <firstname.lastname@example.org>
- Date: Fri, 27 Jul 2001 11:20:39 +0100
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
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" <email@example.com>
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
> where x: is the prefix assigned to the namepace URI dummyNamespace in
> the stylesheet.
> 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