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

1

6

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>
Wauters answered 17/12, 2019 at 18:40 Comment(2)
I can confirm the behaviour. Workaround: <count xsl:expand-text="true">Penholder
Thanks I am not looking for a workaround, this is a test case only.Wauters
K
2

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

Keratosis answered 17/12, 2019 at 22:27 Comment(1)
Thanks Michael, it was just something I stumbled acrossWauters

© 2022 - 2024 — McMap. All rights reserved.