> You are right about the confusing aspects of namespaces, esp. regarding
> XPath expressions. The standard states that namespace prefixes in XPath
> expressions are resolved with regard to the "expression context", which I
> presume is what part of the tree is currently under examination.
> 
> In the following example XML document, the prefix z is mapped to three
> different namespaces on three different elements:
> 
> <?xml version="1.0"?>
> <z:A xmlns:z="urn:zorglub">
>       <z:B xmlns:z="urn:zappa">
>               <z:C xmlns:z="urn:zoot">
>               </z:C>
>       </z:B>
> </z:A>
> 
> If I do selectNodes("//z:*") on the document node I get both z:A, z:B and
> z:C back. 

Nope, that's probably invalid.

'z' can be bound to only (1) namespace within the XPath expression,
not all three. 

Basically, expand the prefix in the xpath, and expand the prefixes
in the document:

<urn:zorglub:A>
   <urn:zappa:B>
       <urn:zoot:C>
       </urn:zoot:C>
   </urn:zappa:B>
</urn:zorglub:A>

And also in the XPath (using the NamespaceContext)

//urn:zorglub:*

And now, you see, you'd only get 1 node.

> Any XPath gurus care to comment?

If you're getting 3 nodes back, it's a bug.

        -bob


_______________________________________________
dom4j-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-user

Reply via email to