Project

Profile

Help

Bug #2944

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

Added by John Lumley about 2 years ago. Updated about 1 year ago.

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

100%

Applies to JS Branch:
0.9
Fix Committed on JS Branch:
0.9
Fixed in JS Release:
SEF Generated with:
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.

History

#1 Updated by Michael Kay about 2 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

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.

#2 Updated by Debbie Lockett almost 2 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.

#3 Updated by Debbie Lockett almost 2 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.

#4 Updated by Debbie Lockett almost 2 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.

#5 Updated by Community Admin about 1 year 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