Previous: Expansion Operations, Up: Expansion Sequence [Contents][Index]
Hoisting is the process of moving a fully expanded head node
out of the expansion sequence; it is the final step of the process
for a head node and is driven wholly by the
eseq:is-expandable#1
predicate.
Unfortunately, we cannot continue processing immediately after hoisting for the same reasons that we cannot continue processing after expansion: after hoisting, the nodes may enter a proper context and acquire another meaning, which may result in, for example, additional symbols.
xmlns:_eseq="http://www.lovullo.com/tame/preproc/expand/eseq/_priv"
Hoisting removes the head node from the expansion sequence, leaving all other expansion nodes untouched. The result is a sequence of two nodes, the last of which is the expansion sequence element.
If no head node exists, the result is the single expansion sequence node unchanged.
Definition:
<function name="_eseq:hoist" as="node()+"> <param name="eseq-node" as="element()" /> <variable name="head" as="node()?" select="$eseq-node/node()[1]" /> <sequence select="$head" /> <!-- This @code{for-each} is purely to set the context for @code{copy}, since we do not know the sequence element name. --> <for-each select="$eseq-node"> <copy> <sequence select="$eseq-node/@* , $head/following-sibling::node()" /> </copy> </for-each> </function>