xsl-list
[Top] [All Lists]

Generic functions over a tree (Was: Re: Repeated Recursion on different parts of a tree)

2002-09-26 08:05:42
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



<Prev in Thread] Current Thread [Next in Thread>
  • Generic functions over a tree (Was: Re: Repeated Recursion on different parts of a tree), Dimitre Novatchev <=