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]

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

This XPath question recently came up on the dom4j-user discussion list, I
wondered if anyone around here knew the answer. (Strictly speaking maybe
XPath questions should be sent to the XSL mail list?)


<a xmlns="dummyNamespace">

Should the path


find the <c> element?

From 2.3 of the XPath spec

"A QName in the node test is expanded into an expanded-name using the
namespace declarations from the expression context. This is the same way
expansion is done for element type names in start and end-tags except that
the default namespace declared with xmlns is not used: if the QName does
not have a prefix, then the namespace URI is null (this is the same way
attribute names are expanded). It is an error if the QName has a prefix
for which there is no namespace declaration in the expression context."

So the default namespace is not used and none of the QNames in the document
or the path have namespace prefixes, so the namespace URI is null for all
the QNames.

So /a/b/c should find <c> because all the namespace URIs match (they are all



Do You Yahoo!?

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