Bug #2944

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

Added by John Lumley over 2 years ago. Updated almost 2 years ago.

Start date:
Due date:
% Done:


Applies to JS Branch:
Fix Committed on JS Branch:
Fixed in JS Release:
SEF Generated with:
Contact person:
Additional contact persons:


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.


#1 Updated by Michael Kay over 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 over 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 over 2 years ago

Various unit tests created for this bug (in combination with for the JS unit testing framework in development.

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