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

[xsl] exclude-result-prefixes issue


Subject: [xsl] exclude-result-prefixes issue
From: Andrew Welch <andrew.j.welch@xxxxxxxxx>
Date: Wed, 6 Nov 2013 16:32:17 +0000

Hi,

This xslt:

<xsl:stylesheet version="2.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:aaa="ns"
    xmlns:bbb="ns"
    exclude-result-prefixes="">

    <xsl:output indent="yes" omit-xml-declaration="yes"/>

    <xsl:template match="/">
        <root>
            <bbb:foo/>
        </root>
    </xsl:template>
</xsl:stylesheet>

produces:

<root xmlns:bbb="ns" xmlns:aaa="ns">
   <bbb:foo/>
</root>

All the namespaces are on the root element as expected.  However if I
modify the xslt to exclude the aaa prefix:

<xsl:stylesheet version="2.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:aaa="ns"
    xmlns:bbb="ns"
    exclude-result-prefixes="aaa">

    <xsl:output indent="yes" omit-xml-declaration="yes"/>

    <xsl:template match="/">
        <root>
            <bbb:foo/>
        </root>
    </xsl:template>
</xsl:stylesheet>

the output now becomes:

<root>
   <bbb:foo xmlns:bbb="ns"/>
</root>

Note that bbb namespace has moved from the root element to where it's
used, rather than staying on the root element - it suggests that
exclude-result-prefixes works at the namespace uri level, rather than
the prefix, is that right?

Tested using Saxon HE 9.5.1.3

thanks

-- 
Andrew Welch
http://andrewjwelch.com


Current Thread
Keywords