Hi Niket,
 
Have a look at this pattern.
 
It gives the basis of a recursive pattern that you could use. Instead of using just a match though, I would suggest having a base element match on that, do an xsl:for-each and then call a template that takes a param (the current node). The template should check to see if it is at position(1) and if it is, you know that you are at the start of a sibling set. Apply any logic you want to do to that node then xsl:for-each on that node calling the same template again pasing through the current node (this is the recursive part. Finally, before exiting the xsl:for-each loop section, do a check to see if it is the last element in the set (last() function I think :), then you can apply any finalising code for that sibling set.
 
I hope that helps.
 
Stephen
 
 
 
 -----Original Message-----
From: Niket Anand [mailto:[EMAIL PROTECTED]]
Sent: Saturday, April 13, 2002 1:13 AM
To: Niket Anand
Subject: making tree like structure using XML,XSP,XSL

Hi All,
I have one function that connect to database and retrive data in form of Hashtable.
My Hashtable may be like this.
MsgID         ParentID                   
1                    0                               
2                    0
3                    0
4                    0
5                    1
6                    1
7                    6
8                    7
9                    2
10                  2
11                  5
12                  5
 
Tree structure would be like this based on MsgID and ParentID
MsgID will be the Id of a tag and parentid is the id of the parent with which it is linked.
1(parent0)
|
|
-------5(child of 1)
        |
        |___11(child of 5)
        |
        |____12(child of 5 and sibling of 11)
____6(child of 1 and sibling of 5)
        |
        |____7(child of 6)
                |
                |___8(child of 7)
2(parent 2)
|
|____9(child of 2)
|
|____10(child of 2)
 
3(parent 3)
 
4(parent 4)
Like this I have to show dynamic tree like structure in HTML form.I am using cocoon2.0
This can be either handled by XSP or XSL or both.
Please suggest me how to solve the recursive loop problem using XSL..
How can I apply logic to have dynamic tree structure building function based on the values of Hashtable keys and values.
Pls suggest  ideas.
Thanks,
Niket
 

Reply via email to