This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Generic functions over a tree (Was: Re: Repeated Recursion on different parts of a tree)
- From: Dimitre Novatchev <dnovatchev at yahoo dot com>
- To: xsl-list at lists dot mulberrytech dot com
- Date: Thu, 26 Sep 2002 08:05:42 -0700 (PDT)
- Subject: [xsl] Generic functions over a tree (Was: Re: Repeated Recursion on different parts of a tree)
- Reply-to: xsl-list at lists dot mulberrytech dot com
Peter Doggett <ee99ppd at brunel dot ac dot uk> wrote:
> Now I dont have a problem with the maths involved (I am developing
> shifting and decimal to hex/binary templates).The problem is that I
> cant dynamically update a variable in XSL while traversing the tree.
> to call a recursive template would require me to keep track of which
> <bitfield> elements I have processed?
>
> Any Ideas?
A general solution corresponding to this very generally described
problem is to use the generic tree-processing templates of FXSL, in
particular "foldl-tree"
http://fxsl.sourceforge.net/articles/FuncProg/3.html#Tree_processing
"foldl-tree" is for trees what foldl is for lists. It traverses all
nodes of a tree and applies a function to the current node and the
current accumulated result.
At the above link there are examples of using foldl-tree:
sumtree - sums the values of all nodes of a tree
producttree - calculates the product of the values of all tree
nodes
tree-labels-list - produces the concatenation of the labels of all
nodes
maptree f - produces another tree by applying f() on each node
Hope this helped.
=====
Cheers,
Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL
__________________________________________________
Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!
http://sbc.yahoo.com
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list