Actions
Bug #4724
closedxsl:iterator/xsl:param is not accepted inside of xsl:accumulator-rule
Start date:
2020-09-05
Due date:
% Done:
100%
Estimated time:
Legacy ID:
Applies to branch:
10, 9.9, trunk
Fix Committed on Branch:
10, trunk
Fixed in Maintenance Release:
Platforms:
Description
On Slack an issue was raised by Tom Hillmann about the use of the $value
variable of an accumulator in the declaration of an xsl:param
inside of an xsl:iterate
.
I think this is a bug in Saxon Java, I have reduced it to:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="3.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="#all"
expand-text="yes">
<xsl:accumulator name="iterate-value-test" as="xs:integer" initial-value="0">
<xsl:accumulator-rule match="foo">
<xsl:iterate select="1">
<xsl:param name="test" select="$value"/>
<xsl:on-completion select="$test"/>
</xsl:iterate>
</xsl:accumulator-rule>
</xsl:accumulator>
<xsl:mode on-no-match="shallow-copy" use-accumulators="iterate-value-test"/>
<xsl:template match="foo">
<xsl:copy>
<xsl:attribute name="accumulator-test" select="accumulator-before('iterate-value-test')"/>
</xsl:copy>
</xsl:template>
<xsl:template match="/" name="xsl:initial-template">
<xsl:next-match/>
<xsl:comment xmlns:saxon="http://saxon.sf.net/">Run with {system-property('xsl:product-name')} {system-property('xsl:product-version')} {system-property('Q{http://saxon.sf.net/}platform')}</xsl:comment>
</xsl:template>
</xsl:stylesheet>
On compilation that gives an error
Error at xsl:param on line 11 column 57 of iterate-accumulator-rule-test1.xsl: XTSE0010 Local variable must be declared within a template or function
Sample input
<root>
<foo>foo 1</foo>
</root>
The code runs fine with xslt3
/Saxon-JS 2 and Node.
The test case
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="3.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="#all"
expand-text="yes">
<xsl:accumulator name="iterate-value-test" as="xs:integer" initial-value="0">
<xsl:accumulator-rule match="foo">
<xsl:iterate select="1">
<xsl:sequence select="$value"/>
</xsl:iterate>
</xsl:accumulator-rule>
</xsl:accumulator>
<xsl:mode on-no-match="shallow-copy" use-accumulators="iterate-value-test"/>
<xsl:template match="foo">
<xsl:copy>
<xsl:attribute name="accumulator-test" select="accumulator-before('iterate-value-test')"/>
</xsl:copy>
</xsl:template>
<xsl:template match="/" name="xsl:initial-template">
<xsl:next-match/>
<xsl:comment xmlns:saxon="http://saxon.sf.net/">Run with {system-property('xsl:product-name')} {system-property('xsl:product-version')} {system-property('Q{http://saxon.sf.net/}platform')}</xsl:comment>
</xsl:template>
</xsl:stylesheet>
runs fine with both Saxon Java and Saxon-JS 2 so it seems the $value
is not correctly set up in Saxon Java for the local parameter binding environment.
Please register to edit this issue
Actions