Bug #2830
closedposition() inside of xsl:for-each-group select="copy-of(root/items/item)" group-adjacent="foo" in streamed mode is wrong
100%
Description
I have run into a problem with Saxon Saxon-EE 9.7.0.6J using the position()
function inside of a <xsl:for-each-group select="copy-of(root/items/item)" group-adjacent="foo">
with a streamable mode, it does not output consecutive numbers 1, 2, 3, 4, ...
as it does with a non-streamable mode but rather the position of the first item of the group in the original group population (e.g. @1, 3, 4, 6, 7@).
The reduced XSLT is
<?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:math="http://www.w3.org/2005/xpath-functions/math" exclude-result-prefixes="xs math"
version="3.0">
<xsl:output indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:mode streamable="yes"/>
<xsl:template match="/">
<root>
<xsl:for-each-group select="copy-of(root/items/item)" group-adjacent="foo">
<group key="{current-grouping-key()}" group-nr="{position()}">
<xsl:copy-of select="current-group()"/>
</group>
</xsl:for-each-group>
</root>
</xsl:template>
</xsl:stylesheet>
And input sample is
<?xml version="1.0" encoding="UTF-8"?>
<root>
<items>
<item id="i1">
<foo>a</foo>
</item>
<item id="i2">
<foo>a</foo>
</item>
<item id="i3">
<foo>b</foo>
</item>
<item id="i4">
<foo>c</foo>
</item>
<item id="i5">
<foo>c</foo>
</item>
<item id="i6">
<foo>d</foo>
</item>
<item id="i7">
<foo>e</foo>
</item>
</items>
</root>
the result I get when running Saxon 9.7 EE from the command line is:
<?xml version="1.0" encoding="UTF-8"?>
<root>
<group key="a" group-nr="1">
<item id="i1">
<foo>a</foo>
</item>
<item id="i2">
<foo>a</foo>
</item>
</group>
<group key="b" group-nr="3">
<item id="i3">
<foo>b</foo>
</item>
</group>
<group key="c" group-nr="4">
<item id="i4">
<foo>c</foo>
</item>
<item id="i5">
<foo>c</foo>
</item>
</group>
<group key="d" group-nr="6">
<item id="i6">
<foo>d</foo>
</item>
</group>
<group key="e" group-nr="7">
<item id="i7">
<foo>e</foo>
</item>
</group>
so the group-nr
values are wrong. Additionally the closing </root>
tag is missing. When I change the mode to @streamable="no"@, I get the wanted, correct result:
<?xml version="1.0" encoding="UTF-8"?>
<root>
<group key="a" group-nr="1">
<item id="i1">
<foo>a</foo>
</item>
<item id="i2">
<foo>a</foo>
</item>
</group>
<group key="b" group-nr="2">
<item id="i3">
<foo>b</foo>
</item>
</group>
<group key="c" group-nr="3">
<item id="i4">
<foo>c</foo>
</item>
<item id="i5">
<foo>c</foo>
</item>
</group>
<group key="d" group-nr="4">
<item id="i6">
<foo>d</foo>
</item>
</group>
<group key="e" group-nr="5">
<item id="i7">
<foo>e</foo>
</item>
</group>
</root>
Exselt also gives the the right position() numbers for the streamable mode version so the problem appears to be a bug in Saxon.
Updated by Michael Kay over 7 years ago
- Status changed from New to In Progress
- Assignee set to Michael Kay
- Priority changed from Low to Normal
Created test case si-group-034.
Updated by Michael Kay over 7 years ago
- Status changed from In Progress to Resolved
- Applies to branch 9.8 added
- Fix Committed on Branch 9.7, 9.8 added
Patched in ForEachGroupAdjunct.GroupedGroundedFeed on the 9.7 and 9.8 branches.
The problem is specific to a streaming xsl:for-each-group where the select expression is consuming and grounded.
Updated by O'Neil Delpratt over 7 years ago
- % Done changed from 0 to 100
- Fixed in Maintenance Release 9.7.0.7 added
Bug fix applied in the Saxon 9.7.0.7 maintenance release.
Updated by O'Neil Delpratt over 7 years ago
- Status changed from Resolved to Closed
Updated by O'Neil Delpratt almost 7 years ago
- Applies to branch trunk added
- Applies to branch deleted (
9.8)
Updated by O'Neil Delpratt almost 7 years ago
- Fix Committed on Branch trunk added
- Fix Committed on Branch deleted (
9.8)
Please register to edit this issue