Serialization difference between Saxon-JS 2 and Saxon Java when using namespace-alias

Added by Martin Honnen 3 months ago

When I run the stylesheet

<xsl:stylesheet xmlns:xsl="" xmlns:custom="custom-uri" xmlns:custom2="custom2-uri" version="3.0"
    <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">
            <xsl:element name="xsl:function">
                <xsl:attribute name="name">whatever</xsl:attribute>
            <xsl:element name="xsl:function">
                <xsl:attribute name="name">whatever2</xsl:attribute>

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"
   <xsl:function name="whatever"/>
   <xsl:function name="whatever2"/>

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="" name="whatever"/>
   <xsl:function xmlns:xsl="" name="whatever2"/>

Reading 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 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