(sxml fold) defines a number of variants of the fold algorithm for use in transforming SXML trees. Additionally it defines the layout operator, fold-layout, which might be described as a context-passing variant of SSAX's pre-post-order.
foldt fup fhere tree | [Function] |
The standard multithreaded tree fold.
fup is of type [a] -> a. fhere is of type object -> a.
fold proc seed list | [Function] |
The standard list fold.
proc is of type a -> b -> b. seed is of type b. list is of type [a].
foldts fdown fup fhere seed tree | [Function] |
The single-threaded tree fold originally defined in SSAX. See (sxml ssax), for more information.
foldts* fdown fup fhere seed tree | [Function] |
A variant of foldts that allows pre-order tree rewrites. Originally defined in Andy Wingo's 2007 paper, Applications of fold to XML transformation.
fold-values proc list . seeds | [Function] |
A variant of fold that allows multi-valued seeds. Note that the order of the arguments differs from that of fold.
foldts*-values fdown fup fhere tree . seeds | [Function] |
A variant of foldts* that allows multi-valued seeds. Originally defined in Andy Wingo's 2007 paper, Applications of fold to XML transformation.
fold-layout tree bindings params layout stylesheet | [Function] |
A traversal combinator in the spirit of SSAX's pre-post-order.
fold-layout was originally presented in Andy Wingo's 2007 paper, Applications of fold to XML transformation.
bindings := (<binding>...)
binding := (<tag> <bandler-pair>...)
| (*default* . <post-handler>)
| (*text* . <text-handler>)
tag := <symbol>
handler-pair := (pre-layout . <pre-layout-handler>)
| (post . <post-handler>)
| (bindings . <bindings>)
| (pre . <pre-handler>)
| (macro . <macro-handler>)A function of three arguments:
the kids of the current node, before traversal
the params of the current node
the layout coming into this node
pre-layout-handler is expected to use this information to return a layout to pass to the kids. The default implementation returns the layout given in the arguments.
A function of five arguments:
the current tag being processed
the params of the current node
the layout coming into the current node, before any kids were processed
the layout after processing all of the children
the already-processed child nodes
post-handler should return two values, the layout to pass to the next node and the final tree.
text-handler is a function of three arguments:
the string
the current params
the current layout
text-handler should return two values, the layout to pass to the next node and the value to which the string should transform.