Project

Profile

Help

Bug #4541

Effect of xs:iterate/xsl:param/@as

Added by Michael Kay over 1 year ago. Updated 11 months ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
XSLT conformance
Sprint/Milestone:
-
Start date:
2020-05-05
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
10, 9.9
Fix Committed on Branch:
10, 9.9
Fixed in Maintenance Release:

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

History

#1 Updated by Michael Kay over 1 year ago

  • Description updated (diff)

#2 Updated by Michael Kay over 1 year 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 on xsl:param or xsl: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 the xsl:iterate case.

So the value should definitely be atomized.

#3 Updated by Michael Kay over 1 year 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.

#4 Updated by Michael Kay over 1 year 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.

#5 Updated by O'Neil Delpratt over 1 year ago

  • % Done changed from 0 to 100
  • Fixed in Maintenance Release 10.1 added

Bug fix committed in the Saxon 10.1 maintenance release.

#6 Updated by O'Neil Delpratt 11 months 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

Also available in: Atom PDF