Serialization difference between Saxon-JS 2 and Saxon Java when using namespace-alias
Added by Martin Honnen over 4 years ago
When I run the stylesheet
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:custom="custom-uri" xmlns:custom2="custom2-uri" version="3.0"
xmlns:axsl="http://www.w3.org/1999/XSL/Transform-alias">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:namespace-alias stylesheet-prefix="axsl" result-prefix="xsl" />
<xsl:template match="/" name="xsl:initial-template">
<custom:element>
<xsl:element name="xsl:function">
<xsl:attribute name="name">whatever</xsl:attribute>
</xsl:element>
<xsl:element name="xsl:function">
<xsl:attribute name="name">whatever2</xsl:attribute>
</xsl:element>
</custom:element>
</xsl:template>
</xsl:stylesheet>
through Saxon Java the XSLT namespace is declared on the root element of the result i.e. the result is
<?xml version="1.0" encoding="UTF-8"?>
<custom:element xmlns:custom="custom-uri"
xmlns:custom2="custom2-uri"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:function name="whatever"/>
<xsl:function name="whatever2"/>
</custom:element>
Saxon-JS 2 (both under node and in the browser) puts it on the two elements in that namespace:
<?xml version="1.0" encoding="UTF-8"?>
<custom:element xmlns:custom2="custom2-uri" xmlns:custom="custom-uri">
<xsl:function xmlns:xsl="http://www.w3.org/1999/XSL/Transform" name="whatever"/>
<xsl:function xmlns:xsl="http://www.w3.org/1999/XSL/Transform" name="whatever2"/>
</custom:element>
Reading https://www.w3.org/TR/xslt-30/#dt-target-namespace-uri and the section
When a literal result element is processed, its namespace nodes are handled as follows:
A namespace node whose string value is a literal namespace URI is not copied to the result tree.
A namespace node whose string value is a target namespace URI is copied to the result tree, whether or not the URI identifies an excluded namespace.
in https://www.w3.org/TR/xslt-30/#namespace-aliasing it seems the declaration for the XSLT namespace should appear on the custom:element
, like Saxon Java does it, and Saxon JS 2's serializer is not getting it right.
Please register to reply