xsl-list
[Top] [All Lists]

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

2011-07-25 12:53:34
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>


to back up what others have said, the serialisation of the test node is as you show, but both nodes have an associated xs namespace node, and if you copy the inner node to a different context where xs is not already in scope then the namespace declaration will be serialised.

modify your xslt so

<xsl:template match="test">
  <xsl:copy-of select="*"/>
</xsl:template>

and you will see

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

David


--
google plus: https:/profiles.google.com/d.p.carlisle

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--