Copying a node other than the last in the list

Mark Birbeck's picture

It is also possible to copy a node from some other location than the last node in the list, by using the origin attribute. The node could be in the target nodelist:

<xf:insert nodeset="list/y" origin="list/y[1]" />

which would give:

<list>
  <y>y1</y>
  <y>y2</y>
  <y>y3</y>
  <y>y1</y>
</list>

But the node to copy need not be in the nodeset being updated, and could come from some other location, such as a collection of templates:

<xf:insert nodeset="list/y" origin="templates/x" />

The result would be:

<list>
  <y>y1</y>
  <y>y2</y>
  <y>y3</y>
  <x>x1</x>
</list>