Project

Profile

Help

copy-namespaces="no" not honoured for (xsi?) namespace

Added by Martin Honnen over 3 years ago

It seems Saxon Java doesn't apply copy-namespaces="no" for the xsi namespaces in the following example: Saxon 10.2 HE Java with

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    exclude-result-prefixes="#all"
    version="3.0">
    
    <xsl:mode on-no-match="shallow-copy"/>
    
    <xsl:template match="bar" xpath-default-namespace="http://example.org">
        <xsl:variable name="bar-copy" as="element()">
            <xsl:copy-of select="." copy-namespaces="no"/>
        </xsl:variable>
        <xsl:value-of select="serialize($bar-copy)"/>
    </xsl:template>
    
</xsl:stylesheet>

when run against the input

<?xml version="1.0" encoding="UTF-8"?>
<root xmlns="http://example.com"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <foo>
        <bar xmlns="http://example.org">test</bar>
    </foo>
</root>

outputs

<?xml version="1.0" encoding="UTF-8"?><root xmlns="http://example.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <foo>
        &lt;bar xmlns="http://example.org" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;test&lt;/bar&gt;
    </foo>
</root>

With Saxon-JS 2/xslt3 the result is

<?xml version="1.0" encoding="UTF-8"?><root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://example.com">
    <foo>
        &lt;bar xmlns="http://example.org"&gt;test&lt;/bar&gt;
    </foo>
</root>

So the difference is the presence of xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;test&lt;/bar&gt; for Saxon Java on the element created with xsl:copy-of copy-namespaces="no".

I see no special treatment prescribed in the XSLT 3 spec for copy-namespaces="no" and the schema instance namespace so Saxon Java's result seems a bug.


Replies (1)

RE: copy-namespaces="no" not honoured for (xsi?) namespace - Added by Michael Kay over 3 years ago

Logged here

https://saxonica.plan.io/issues/4793

with a new test case copy-5101.

The particular circumstances causing the problem are (a) Saxon is able to create a virtual copy of the node rather than a physical copy, and (b) the virtual copy is then pushed (decomposed to a set of push events) to a destination such as a serializer.

    (1-1/1)

    Please register to reply