13. replace

replace(replacement, replaced?)

Replace node replaced by replacement, one or more nodes. Parameter replaced defaults to the context node.

Important note: Always pass detached nodes as the first argument of insert or replace.

Examples:

replace(copy(./node()));

replace(<img src="{translate(@src, '\', '/')}"
             alt="{if(@o:title != '', @o:title, '???')}"/>,
        $parent);