Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XSLT3 can disable-output-escaping be used in same template as expand-text=yes?

I noticed when trying to use disable-output escaping in XSLT3 in Saxon that it would not work if expand-text was set to yes on the stylesheet or even on the given match template

The following code (when run on itself) shows the issue (in Saxon 9.8.0.12). I know this is an unusual combination and that disable-output-escaping in normally to be avoided at all costs but just trying to ascertain correct behavior.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0">

    <xsl:template match="/">
        <out>
            <xsl:apply-templates/>
        </out>
    </xsl:template>
    <xsl:template match="xsl:stylesheet" expand-text="true">
        <expandtext>
            <count>{count(*)}</count>
            <xsl:text disable-output-escaping="true">&lt;test/&gt;</xsl:text>
        </expandtext>
        <xsl:apply-templates/>
    </xsl:template>
    <xsl:template match="xsl:template" expand-text="false">
        <notexpandtext>
            <count>{count(*)}</count>
            <xsl:text disable-output-escaping="true">&lt;test/&gt;</xsl:text>
        </notexpandtext>
    </xsl:template>
</xsl:stylesheet>

produces

<?xml version="1.0" encoding="UTF-8"?>
<out>
    <expandtext><count>3</count>&lt;test/&gt;</expandtext>
    <notexpandtext><count>{count(*)}</count><test/></notexpandtext>
    <notexpandtext><count>{count(*)}</count><test/></notexpandtext>
    <notexpandtext><count>{count(*)}</count><test/></notexpandtext>
</out>
like image 804
Colin Mackenzie Avatar asked Dec 17 '19 18:12

Colin Mackenzie


1 Answers

Indeed there is a bug here, which I have logged at

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

An xsl:text instruction within the scope of expand-text="yes" is implemented internally as a different kind of expression from a "plain old" xsl:text element, and the new expression overlooked the need to support d-o-e.

I have added a test case disable-output-escaping/doe-0201 to the XSLT 3.0 test suite at https://github.com/w3c/xslt30-test

like image 51
Michael Kay Avatar answered Oct 17 '22 22:10

Michael Kay