[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Generic functions over a tree (Was: Re: Repeated Recur

Subject: Generic functions over a tree (Was: Re: Repeated Recursion on different parts of a tree)
From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Thu, 26 Sep 2002 08:05:42 -0700 (PDT)
functions of a tree
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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.