Project

Profile

Help

Bug #5190

closed

xsl:iterate problem where the name of an xsl:iterate parameter duplicates the name of a local variable

Added by Martin Honnen almost 3 years ago. Updated over 2 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
XSLT Conformance
Sprint/Milestone:
Start date:
2021-12-26
Due date:
% Done:

100%

Estimated time:
Applies to JS Branch:
2
Fix Committed on JS Branch:
2
Fixed in JS Release:
SEF Generated with:
Platforms:
Company:
-
Contact person:
-
Additional contact persons:
-

Description

I was experimenting with xsl:iterate and found that the code

<?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:output method="xml" indent="yes"/>

  <xsl:mode on-no-match="shallow-copy"/>

  <xsl:template match="table">
    <xsl:copy>
      <xsl:iterate select="row">
        <xsl:param name="row" as="element(row)?" select="()"/>
        <xsl:on-completion select="$row"/>
        <xsl:variable name="row" as="element(row)">
          <xsl:apply-templates select="."/>
        </xsl:variable>
        <xsl:copy-of select="$row"/>
        <xsl:next-iteration>
          <xsl:with-param name="row" select="$row"/>
        </xsl:next-iteration>
      </xsl:iterate>
    </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>

when run with xslt3 from Saxon-JS 2.3 against a sample like

<table>
  <row>row 1</row>
  <row>row 2</row>
  <row>row 3</row>
</table>

outputs "only" three rows

<?xml version="1.0" encoding="UTF-8"?>
<table>
   <row>row 1</row>
   <row>row 2</row>
   <row>row 3</row>
</table>
<!--Run with Saxon-JS 2.3 Node.js-->

while Saxon HE Java 10.6 outputs the third row two times

<?xml version="1.0" encoding="UTF-8"?>
<table>
   <row>row 1</row>
   <row>row 2</row>
   <row>row 3</row>
   <row>row 3</row>
</table>
<!--Run with SAXON HE 10.6 -->

as does SaxonCS.

The spec for xsl:iterate https://www.w3.org/TR/xslt-30/#iterate states that "The result of the xsl:iterate instruction is the concatenation of the sequences that result from the repeated evaluation of the contained sequence constructor, followed by the sequence that results from evaluating the xsl:break or xsl:on-completion element if any" so I think Saxon-JS has a bug here, failing to output the on-completion result.

Please register to edit this issue

Also available in: Atom PDF Tracking page