Project

Profile

Help

Bug #2944

closed

Use of xsl:sequence within copy situations is node-destructive

Added by John Lumley about 8 years ago. Updated over 7 years ago.

Status:
Closed
Priority:
Normal
Category:
-
Sprint/Milestone:
-
Start date:
2016-09-17
Due date:
% Done:

100%

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

Description

When @$nodes instance of node()*@, then the following:

<a><xsl:sequence select="$nodes/></a>
<b><xsl:sequence select="$nodes/></b>

inserts $nodes only into the second element - within Dom node-insertion removes nodes from any trees they were in previously. With xsl:copy-of the behaviour is as expected.

Actions #1

Updated by Michael Kay about 8 years ago

Clearly this can be fixed by creating a copy of the node before appending it.

It would be nice, however, to avoid doing a double copy in the case of

<xsl:copy-of select="$x"/>

One way to achieve this would be to rewrite xsl:copy-of appearing within an element constructor as xsl:sequence at compile time (under appropriate circumstances) - which might be beneficial generally. In fact, I have a feeling we have started doing this for streaming purposes.

Actions #2

Updated by Debbie Lockett about 8 years ago

  • Status changed from New to Resolved
  • Found in version set to 0.9

Fixes in makeComplexContent method of Expr.js. When adding an element to a parent, we can't just append an element directly. In the browser, for HTML elements, these should be copies of the original elements (constructed using DU.copyItem). Otherwise, use the Document.importNode method.

Actions #3

Updated by Debbie Lockett about 8 years ago

Various unit tests created for this bug (in combination with https://saxonica.plan.io/issues/3012#change-7416) for the JS unit testing framework in development.

Actions #4

Updated by Debbie Lockett almost 8 years ago

  • Status changed from Resolved to Closed
  • % Done changed from 0 to 100
  • Fixed in version set to 0.9.1

Bug fix applied in the Saxon-JS 0.9.1 beta release.

Actions #5

Updated by Community Admin over 7 years ago

  • Fixed in JS Release set to Saxon-JS 0.9.1
  • Applies to JS Branch 0.9 added
  • Fix Committed on JS Branch 0.9 added

Please register to edit this issue

Also available in: Atom PDF Tracking page