Re: [xsl] How do I force the XSLT processor to retain a namespace declaration despite an ancestor element having that same namespace declaration?

Subject: Re: [xsl] How do I force the XSLT processor to retain a namespace declaration despite an ancestor element having that same namespace declaration?
From: Michael Kay <mike@xxxxxxxxxxxx>
Date: Mon, 25 Jul 2011 22:55:15 +0100
On 25/07/2011 18:05, Costello, Roger L. wrote:
Hi Folks,

When this is evaluated:

     <test xmlns:xs="http://www.w3.org/2001/XMLSchema";>
         <inner xmlns:xs="http://www.w3.org/2001/XMLSchema"; type="xs:string" />
     </test>

The output is this:

     <test xmlns:xs="http://www.w3.org/2001/XMLSchema";>
         <inner type="xs:string" />
     </test>

Notice that the namespace declaration on<inner> is gone.
In the XDM data model, there is no difference between these two documents. A processor that is using XDM cannot tell the difference between them.
How do I force the XSLT processor to retain that namespace declaration and not discard it? (I am passing the<inner> element to other functions that don't have access to its surrounding elements, so I need that namespace declaration retained.)

The function is doing something wrong. If it uses XDM interfaces to access the document, it won't see any difference between them. If it's using DOM interfaces, that's another matter...

Michael Kay
Saxonica

Current Thread