Project

Profile

Help

Bug #2562

closed

Missing end tag in result after using xsl:break

Added by Michael Kay over 8 years ago. Updated over 8 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Streaming
Sprint/Milestone:
-
Start date:
2015-12-28
Due date:
% Done:

100%

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

Description

See https://saxonica.plan.io/boards/3/topics/6262

Saxon - Help: Getting incomplete result document when using xsl:break in xsl:iterate in xsl:copy with streaming mode

Martin Honnen

I am getting an incomplete result document with a missing closing end tag of the root element when using the following stylesheet with Saxon 9.7 EE:

<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="xs">

<xsl:param name="elements-to-copy" as="xs:integer" select="5"/>

<xsl:mode streamable="yes"/>

<xsl:output indent="yes"/>

<xsl:template match="/*">

xsl:copy

<xsl:iterate select="*">

  <xsl:copy-of select="."/>

  <xsl:if test="position() eq $elements-to-copy">

    <xsl:break/>

  </xsl:if>

</xsl:iterate>

</xsl:copy>

</xsl:template>

</xsl:stylesheet>

The input document is

...

...

...

...

...

...

...

...

The output is lacking the closing end tag of the root element:

...

...

...

...

...

As the xsl:copy is outside of the xsl:iterate I would expect the root element to be closed properly.

Actions #1

Updated by Michael Kay over 8 years ago

  • Status changed from New to In Progress

Trying to reproduce this, I hit a secondary problem: running a transformation from the command line, if there is no global context item declaration, we build the source document as a tree regardless whether the initial mode is streamable. See Transform line 1193.

Actions #2

Updated by Michael Kay over 8 years ago

The problem is that xsl:break, under the conditions of this test, causes parsing of the input file to be aborted because no more input is required; but the writing of end tags in the output file is only triggered by the processing of end tags in the input file.

Actions #3

Updated by Michael Kay over 8 years ago

I have a solution that works for this test case, which involves WatchManager.endElement() catching the QuitParsingException and calling endElement() for all open elements on the stack, before re-throwing the exception. Need to do further testing to establish that this has no adverse side-effects. Also, we are catching the QuitParsingException where it occurs in this test case (during endElement processing) and it's not obvious that this will catch all cases where the same problem might occur.

Actions #4

Updated by Michael Kay over 8 years ago

  • Status changed from In Progress to Resolved
  • Fix Committed on Branch 9.7 added

This fix is now tested. Raising a separate bug for the "secondary issue" that streaming doesn't work from the command line.

Actions #5

Updated by O'Neil Delpratt over 8 years ago

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

Bug fix applied in the Saxon 9.7.0.2 maintenance release

Actions #6

Updated by O'Neil Delpratt over 8 years ago

  • Status changed from Resolved to Closed

Please register to edit this issue

Also available in: Atom PDF