Subject: Re: [xsl] Generating a tree From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx> Date: Tue, 04 May 2004 17:05:02 -0400 |
starting at the document element (not the root node) A. process all its children with each child encountered: if it is an ancestor-or-self of your target node mark with 'minus', and if it's an ancestor, return to A if it's the target node, just write the children if not if it has children, mark with 'plus' in any case, write it out
Ask again if I'm being too sketchy here. And good luck, Wendell
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.
====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Generating a tree, Marcus Andersson | Thread | Re: [xsl] [solved]Generating a tree, Marcus Andersson |
[xsl] XSL-output for xml without pa, Bret | Date | Re: [xsl] [solved]Generating a tree, Marcus Andersson |
Month |