Next: , Previous: , Up: SXML   [Contents][Index]

7.22.8 (sxml apply-templates) Overview

Pre-order traversal of a tree and creation of a new tree:

	apply-templates:: tree x <templates> -> <new-tree>


 <templates> ::= (<template> ...)
 <template>  ::= (<node-test> <node-test> ... <node-test> . <handler>)
 <node-test> ::= an argument to node-typeof? above
 <handler>   ::= <tree> -> <new-tree>

This procedure does a normal, pre-order traversal of an SXML tree. It walks the tree, checking at each node against the list of matching templates.

If the match is found (which must be unique, i.e., unambiguous), the corresponding handler is invoked and given the current node as an argument. The result from the handler, which must be a <tree>, takes place of the current node in the resulting tree. The name of the function is not accidental: it resembles rather closely an apply-templates function of XSLT. Usage

Scheme Procedure: apply-templates tree templates