Previous: , Up: Node Constructors   [Contents]


3.2 Node Mutators

A node mutator produces an altered copy of an existing node.

function: element() n:add-attributes (element as element(), attrs as attribute()*)

xmlns:n="http://mikegerwitz.com/hoxsl/node"

Create a copy of element with additional attributes defined by attrs, replacing attributes that already exist with the same QName.

Attributes that already exist on element but are not specified in attrs will be left untouched. All child nodes of element are retained by reference.

Definition:

<function name="n:add-attributes"  as="element()">
  <param name="element"  as="element()" />
  <param name="attrs"  as="attribute()*" />

  <sequence select="if ( empty( $attrs ) ) then $element else n:element( node-name( $element ), ( $element/@*, $attrs ), $element/node() )" />
</function>