[Bug 5857] New: [XSLT 2.0] A problem with namespace inheritance

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

           Summary: [XSLT 2.0] A problem with namespace inheritance
           Product: XPath / XQuery / XSLT
           Version: Recommendation
          Platform: PC
        OS/Version: Windows NT
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XSLT 2.0
        AssignedTo: mike@saxonica.com
        ReportedBy: mike@saxonica.com
         QAContact: public-qt-comments@w3.org


We all know that this is an identity template, don't we:

<xsl:template match="*">
  <xsl:copy>
    <xsl:copy-of select="@*"/>
    <xsl:apply-templates/>
  </xsl:copy>
</xsl:template>

Well, a Saxon user [see [1]] has just discovered that it isn't. Consider the
following input 

<s:complexType xmlns:s="http://s.com/" xmlns="http://t.com/">
  <s:element ref="abcd" xmlns=""/>
</s:complexType>

The result of applying the transform is:

<s:complexType xmlns:s="http://www.w3.com/schema" xmlns="http://t.com/">
  <s:element ref="abcd"/>
</s:complexType>

which loses the xmlns="" undeclaration, and (because the source document is
actually a schema and @ref is a QName) causes @ref to be a different QName from
the one intended.

How is this happening? We have a bottom-up construction model. <xsl:copy>
applied to the <s:element> creates an element with two namespace nodes (for
prefixes "s", and "xml"). <xsl:copy> applied to the <s:complexType> creates an
element with three namespace nodes (for prefixes "s", "xml", and ""). Then
5.7.1 Constructing Complex Content kicks in, and rule 12 says that these three
namespace nodes are inherited by the copied children. So the copied <s:element>
acquires a namespace node for ("", "http://t.com"), and therefore no xmlns=""
undeclaration appears in the serialized output.

The user can fix this by writing <xsl:copy inherit-namespaces="no">. But should
they have to?

Should we perhaps modify the namespace inheritance rule (rule 12) so it does
not apply to the default namespace? There's a good reason for making a
difference - whereas a 1.1-style undeclaration xmlns:p="" makes p unavailable
for use and therefore losing the undeclaration is fairly harmless, the 1.0
undeclaration xmlns="" makes "" refer to a different namespace URI, so losing
the undeclaration really matters. 

[1] https://sourceforge.net/forum/message.php?msg_id=5089774


-- 
Configure bugmail: http://www.w3.org/Bugs/Public/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.

Received on Friday, 11 July 2008 19:32:14 UTC