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

Re: [xsl] Why doesn't copy xmlns=""?


Subject: Re: [xsl] Why doesn't <xsl:copy> copy xmlns=""?
From: Michael Kay <mike@xxxxxxxxxxxx>
Date: Sat, 17 Nov 2012 19:54:01 +0000

If the xmlns="" appears on the outermost element then the XDM data model is indistinguishable from one in which the xmlns="" is absent - so the XSLT processor doesn't know it's there.

If it appears elsewhere the question gets terribly complicated: see

https://www.w3.org/Bugs/Public/show_bug.cgi?id=5857

Michael Kay
Saxonica


On 17/11/2012 13:39, Costello, Roger L. wrote:
Hi Folks,

I want to do an identity transform of this:
----------------------------------------------------------------------------
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.bar.com"
xmlns:bar="http://www.bar.com"
xmlns=""
elementFormDefault="qualified">
...


</xs:schema>
----------------------------------------------------------------------------

Notice the default namespace declaration, xmlns=""

Here is the code that I use to do the identity transform:

     <xsl:template match="xs:schema">
         <xsl:copy>
             <xsl:copy-of select="@*" />
             <xsl:sequence select="node() | comment() | processing-instruction()" />
         </xsl:copy>
     </xsl:template>

(I use this code because I actually do more than just an identity transform, which I do not show here.)

Here is the output from transforming the <xs:schema> with my code:
----------------------------------------------------------------------------
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.bar.com"
xmlns:bar="http://www.bar.com"
elementFormDefault="qualified">
...


</xs:schema>
----------------------------------------------------------------------------

Yikes!

What happened to the default namespace declaration?

Questions:

1. Why is my code not copying over the default namespace declaration?

2. What change can I make to my code to ensure that it copies over the default namespace declaration?

/Roger


Current Thread
Keywords