xsl-list
[Top] [All Lists]

[recursion pattern] sophisticated problem

2003-09-16 08:36:10
Hi,

I'm trying to find a solution for copying an existing tree with an identity 
transformation.
Some nodes should be modified. For the most tasks I have a solution but this 
one.

Transforming a node like this:
----------------
input tree:
/context-node/
        +-/ A /
        +-/ B /
        +-/ C mode="x" /
        +-/ D mode="x" /
        +-/ E /
        +-/ F /
-----------------
result tree:
/context-node/
        +-/ A /
        +-/ B /
        +-/ X /
                +-/ C mode="x" /
                +-/ D mode="x" /
        +-/ E /
        +-/ F /
===========

My approach uses the recursion pattern (Kay 2001 p. 614) to iterate through the 
child node list.
The best I've got so far is:
-----------------
result tree:
/context-node/
        +-/ A /
        +-/ B /
        +-/ X /
                +-/ C mode="x" /
                +-/ D mode="x" /
                +-/ E /
                +-/ F /
===========

I think this is so because the recursion levels lay upon each other and 
inserting the X node in one
effects the rest node list even if I test for 'not mode' Nodes.

Question: Is the recursion pattern the best way to do the job and I only need 
to do more reasoning?
Or, does anyone know an alternative way to do that?

Romeo


-- 
Romeo Disca
Email: romeo(_dot_)disca(_at_)t-online(_dot_)de

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list