Bug #4541
closedEffect of xs:iterate/xsl:param/@as
100%
Description
Raised on Slack at xml.com by Martin Honnen:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:mf="http://example.com/mf"
exclude-result-prefixes="#all"
version="3.0">
<xsl:output method="html" indent="yes" html-version="5"/>
<xsl:template match="/" name="xsl:initial-template">
<html>
<head>
<title>Some xsl:param tests with as attribute</title>
</head>
<body>
<h1>Some <code>xsl:param</code> tests with <code>as</code> attribute</h1>
<section>
<h2>iteration parameter</h2>
<p><code>
<xsl:iterate select="1 to 5">
<xsl:param name="p1" as="xs:string" select="''"/>
<xsl:on-completion>
<xsl:copy-of select="$p1"/>
</xsl:on-completion>
<xsl:next-iteration>
<xsl:with-param name="p1"><item>test</item></xsl:with-param>
</xsl:next-iteration>
</xsl:iterate>
</code></p>
</section>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
The output with Saxon 10 HE is
<!DOCTYPE HTML><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Some xsl:param tests with as attribute</title>
</head>
<body>
<h1>Some <code>xsl:param</code> tests with <code>as</code> attribute</h1>
<section>
<h2>iteration parameter</h2>
<p><code>
<item>test</item></code></p>
</section>
</body>
</html>
with Exselt I only get a string and no element:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Some xsl:param tests with as attribute</title>
</head>
<body>
<h1>Some <code>xsl:param</code> tests with <code>as</code> attribute
</h1>
<section>
<h2>iteration parameter</h2>
<p><code>test</code></p>
</section>
</body>
</html>
So it appears that the node supplied by xsl:with-param
isn't being atomized as required by the @as
option on xsl:param
Updated by Michael Kay over 4 years ago
Looking at the XSLT 3.0 spec:
-
The spec of
xsl:iterate
(in §7.2) doesn't say anything specific about the effect of the@as
attribute onxsl:param
orxsl:with-param
. -
But §9.2.1, relating to
xsl:param/@as
is clear enough: "The supplied value of the parameter is converted to the required type using the function conversion rules.", and there's nothing here that makes this inapplicable to thexsl:iterate
case.
So the value should definitely be atomized.
Updated by Michael Kay over 4 years ago
The failure occurs when the xsl:with-param
instruction has no select attribute, but supplies its value using a contained sequence constructor. This is because we do type-checking differently for the two cases, and in the latter case it isn't happening. I think this might also affect xsl:with-param
for named template parameters, though I haven't confirmed this.
Updated by Michael Kay over 4 years ago
- Status changed from New to Resolved
- Applies to branch 10, 9.9 added
- Fix Committed on Branch 10, 9.9 added
Fixed. Added test case iterate-042.
The fix involves a fairly tortuous addition to StyleElement.getWithParamInstructions() -- couldn't find a more straightforward solution.
Updated by O'Neil Delpratt over 4 years ago
- % Done changed from 0 to 100
- Fixed in Maintenance Release 10.1 added
Bug fix committed in the Saxon 10.1 maintenance release.
Updated by O'Neil Delpratt about 4 years ago
- Status changed from Resolved to Closed
- Fixed in Maintenance Release 10.2, 9.9.1.8 added
- Fixed in Maintenance Release deleted (
10.1)
Bug fix applied on the Saxon 9.9.1.8 maintenance release.
Please register to edit this issue