[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] XPath and namespace nodes: a tough one


Subject: RE: [xsl] XPath and namespace nodes: a tough one
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Fri, 19 Dec 2008 14:53:09 -0000

> this is then enveloped in another document:
> 
>     <n0:pdu xmlns:n0="http://a.example">
>        <n1:elem1 xmlns:n1="http://b.example">
>            content
>        </n1:elem1>
>     </n0:pdu>
> 
> 
> I'm trying to find an *XPath 1.0* (not XSLT) expression that 
> will only include visibly utilized namespace nodes on an 
> element. That is, applied to the above document I want to select
> 
>   <n1:elem1 xmlns:n1="http://b.example">
>         content
>     </n1:elem1>
> 
> I'm beginning to think that isn't possible. Any ideas?
> 

XPath (both 1.0 and 2.0) can only select nodes that are present in your
input, it can't create new or modified nodes. The output you show is not the
serialization of any node that's present in your input, therefore it can't
be produced using XPath alone. (Nothing to do with namespaces - the same
would be true if you wanted to leave out an attribute).

Of course with Namespaces 1.1 you could wrap the inner document in the
envelope without namespace leakage using a namespace undeclaration, which
would seem to solve the problem in this case.

Michael Kay
http://www.saxonica.com/


Current Thread
Keywords