Project

Profile

Help

Bug #4493

closed

end tag not written when using xsl:iterate/xsl:break with early exit

Added by Martin Honnen about 4 years ago. Updated almost 4 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Streaming
Sprint/Milestone:
-
Start date:
2020-03-22
Due date:
% Done:

100%

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

Description

I have a stylesheet using streaming and xsl:iterate with xsl:break doing some early exit, in Saxon 9.9 the result is well-formed document but with 10 the end tag of the root element (created as a literal result element) is missing.

XSLT:

<?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:saxon="http://saxon.sf.net/"
    exclude-result-prefixes="#all" version="3.0">
    
    <xsl:output indent="yes"/>
    
    <xsl:mode streamable="yes" on-no-match="shallow-skip"/>
    
    <xsl:template match="/">
        <items>
            <xsl:iterate select="root/items/item">
                <xsl:copy-of select=".[@cat != 'bar']"/>
                <xsl:if test="@cat = 'bar'">
                    <xsl:break/>
                </xsl:if>
            </xsl:iterate>
        </items>
    </xsl:template>
    
</xsl:stylesheet>

XML:

<?xml version="1.0" encoding="UTF-8"?>
<root>
    <items>
        <item cat="foo">
            <value>item 1</value>
        </item>        
        <item cat="foo">
            <value>item 2</value>
        </item>
        <item cat="foo">
            <value>item 3</value>
        </item>
        <item cat="foo">
            <value>item 4</value>
        </item>
        <item cat="foo">
            <value>item 5</value>
        </item>
        <item cat="bar">
            <value>item 6</value>
        </item>
        <item cat="bar">
            <value>item 7</value>
        </item>
        <item cat="bar">
            <value>item 8</value>
        </item>
        <item cat="bar">
            <value>item 9</value>
        </item>
    </items>
</root>

Output with Saxon-EE 10.0J:

<?xml version="1.0" encoding="UTF-8"?>
<items>
   <item cat="foo">
      <value>item 1</value>
   </item>
   <item cat="foo">
      <value>item 2</value>
   </item>
   <item cat="foo">
      <value>item 3</value>
   </item>
   <item cat="foo">
      <value>item 4</value>
   </item>
   <item cat="foo">
      <value>item 5</value>
   </item>

Output with Saxon-EE 9.9.1.7J:

<?xml version="1.0" encoding="UTF-8"?>
<items>
   <item cat="foo">
      <value>item 1</value>
   </item>
   <item cat="foo">
      <value>item 2</value>
   </item>
   <item cat="foo">
      <value>item 3</value>
   </item>
   <item cat="foo">
      <value>item 4</value>
   </item>
   <item cat="foo">
      <value>item 5</value>
   </item>
</items>

Files

input1.xml (762 Bytes) input1.xml Martin Honnen, 2020-03-22 14:01
iterate-break2.xsl (686 Bytes) iterate-break2.xsl Martin Honnen, 2020-03-22 14:01

Please register to edit this issue

Also available in: Atom PDF