[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Iterate through tree structure
Jim,
If I understand this correctly, you don't actually have to recursively call a template. You only have to iterate through (a) ancestor dir elements of your parent::dir, and then (2) the parent dir element (and maybe its descendants). The reason I say "maybe" is that the source as offered gives two page6 pages: At 11:28 AM 3/31/2009, you wrote: <dir name="dir1" id="x1"> <page pname = "page1"></page> <dir name="dir2" id="x2"> <page pname = "page2"></page> <dir name="dir3" id="x3"> <page pname = "page3"></page> </dir> <dir name="dir4" id="x4"> <page pname = "page4"></page> <dir name="dir5" id="x5"> <page pname = "page5"></page> <page pname = "page6"></page> <dir name="dir6" id="x6"> <page pname = "page6"></page> </dir> </dir> </dir> </dir> </dir> So we don't know on what basis the dir6 is included in the result you say you want. The above is a snapshot as it can go down "n" levels. If I'm at page6 then my navigation needs to be:- In any case, something like this (assuming the second page6 in your stated source is erroneous): <xsl:template match="page6"> <ul> <xsl:apply-templates mode="list-dir" select="parent::dir/ancestor::dir"/> <!-- apply-templates generates output ordered as they are in the source, so this will get dir1, dir2, dir4 --> </ul> <ul> <xsl:apply-templates mode="list-dir" select="parent::dir/descendant-or-self::dir"/> <!-- this gets dir5 (the parent of page6) and dir6 (the dir inside dir5) --> </ul> </xsl:template> I hope that helps -- Wendell ====================================================================== 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 ======================================================================
|
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
|