Bug #2841
closedclosing tag of result elements missing when using streamed grouping of grounded nodes
100%
Description
In https://saxonica.plan.io/issues/2830, besides the main issue about the position() being wrong, I also reported that "the closing tag is missing". Unfortunately while the latest release fixes the main issue, the problem about the missing closing tag does not seem to have been fixed.
It seems a general problem with streamed grouping of grounded nodes and result elements as a wrapper, for instance when I run
<?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:strip-space elements="*"/>
<xsl:output indent="yes"/>
<xsl:mode streamable="yes" on-no-match="shallow-copy"/>
<xsl:template match="books">
<root>
<subjects>
<xsl:for-each-group select="copy-of(book)" group-by="subject">
<subject name="{current-grouping-key()}">
<xsl:apply-templates select="current-group()"/>
</subject>
</xsl:for-each-group>
</subjects>
</root>
</xsl:template>
<xsl:template match="book/subject"/>
</xsl:stylesheet>
against
<?xml version="1.0" encoding="UTF-8"?>
<books>
<book>
<title>book 1</title>
<subject>XSLT</subject>
</book>
<book>
<title>book 2</title>
<subject>XQuery</subject>
</book>
<book>
<title>book 3</title>
<subject>XSLT</subject>
</book>
<book>
<title>book 4</title>
<subject>C#</subject>
</book>
</books>
then the result using Saxon Saxon-EE 9.7.0.7J from the command line is
<?xml version="1.0" encoding="UTF-8"?>
<root>
<subjects>
<subject name="XSLT">
<book>
<title>book 1</title>
</book>
<book>
<title>book 3</title>
</book>
</subject>
<subject name="XQuery">
<book>
<title>book 2</title>
</book>
</subject>
<subject name="C#">
<book>
<title>book 4</title>
</book>
</subject>
with both end tags of the result elements missing.
Updated by Michael Kay almost 8 years ago
It was OK when I tested it, but we'll obviously have to take another look.
Updated by Michael Kay almost 8 years ago
It seems this test (and the other previous tests that showed the problem) are delivering correct results when run from the test driver, but not when run from the command line. The most obvious difference is that the test driver creates a result tree and compares this against the expected results using saxon:deep-equal(), while the command line serializes the result to lexical XML.
(Clearly, however else things might fail, you aren't going to get missing end tags if you don't serialize the result)
This is consistent with the streamed for-each-group code failing to call endElement() on the result destination. If the destination is a tree builder, endElement doesn't do anything other than decrement the current depth in the tree; but if the destination is a serializer, endElement() writes the end tag.
Updated by Michael Kay almost 8 years ago
- Status changed from New to Resolved
- Assignee set to Michael Kay
- Priority changed from Low to Normal
- Applies to branch 9.8 added
- Fix Committed on Branch 9.7, 9.8 added
Added as test case si-group-036, though it doesn't actually reveal the bug under the Saxon test driver because the result isn't serialized.
Fixed by adding a call to super.close() in ForEachGroupAdjunct.GroupedGroundedDistributedFeed.close().
Patch committed to 9.7 and 9.8 branches.
Updated by O'Neil Delpratt over 7 years ago
- % Done changed from 0 to 100
Bug fix applied in the Saxon 9.7.0.8 maintenance release.
Updated by O'Neil Delpratt over 7 years ago
- Status changed from Resolved to Closed
- Fixed in Maintenance Release 9.7.0.8 added
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