[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Generating a tree
Hi gurus
I want to generate an "unfolded" tree down to a selected element. So I want to render all ancestors to the selected element and all their siblings but not the siblings children. Also, the root shouldn't be included and I don't want the siblings to the top-level (below the root element) ancestor to be included. Another wish is that if the selected element is a section element I also want to render it's children (just one level though). Example source XML: <site> <section name="level1_1"> <section name="level2_1> <page name="level3_1"/> </section> <section name="level2_2"/> <page name="level2_3"/> <page name="level2_4"/> <section name="level2_5"> <section name="level3_1"> <page name="level4_1"/> </section> <page name="level3_2"/> <section name="level3_3"> <-- Selected element <page name="level4_1"/> <page name="level4_2"/> </section> <page name="level3_4"/> </section> </section> <page name="level1_2"/> <section name="level1_3"> ... </section> </site> Wanted result (with indents and everything :) : node name="level1_1" node name="level2_1" node name="level2_2" node name="level2_3" node name="level2_4" node name="level2_5" node name="level3_1" node name="level3_2" node name="level3_3" node name="level4_1" //shouldn't be rendered if page node name="level4_2" //shouldn't be rendered if page node name="level3_4" It would also be nice if one could draw something extra to indicate whether the node has children or not (like a plus or minus...). How would you do it? I've made a couple of tries with anscestor-or-self::etc but I just tangle myself into hairy loops. The template/templates that will do this will be called on the selected element level. /Marcus ps. I'm using MSXML so node-set() is available.
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|