[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: recursion questions

Subject: Re: recursion questions
From: Robert Koberg <rob@xxxxxxxxxx>
Date: Tue, 30 Jan 2001 15:06:22 -0800
recursion questions
To save somebody the time trying to explain the basics to me... I figured it
out. It was much simpler than I thought.  Anyway, here is the template I
came up with that produces (most of) the desired results:

<xsl:template match="section">
   <xsl:variable name="folder" select="@folder"/>

   <xsl:value-of select="$folder"/> = new List(true, width, height,
"#EEEEEE");
   <xsl:value-of select="$folder"/>.onexpand = colorize;
   <xsl:value-of select="$folder"/>.setFont(<![CDATA["<FONT
FACE='Arial,Helvetica' SIZE='-1'>","</FONT>"]]>);

   <xsl:apply-templates select="section"/>
   <xsl:variable name="parent.folder" select="parent::section/@folder"/>
   <xsl:if test="$parent.folder!=''">
      <xsl:value-of select="$parent.folder"/>.addList(<xsl:value-of
select="$folder"/>, "<xsl:value-of select="@label"/>");
   </xsl:if>
</xsl:template>


----- Original Message -----
From: "Robert Koberg" <rob@xxxxxxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Tuesday, January 30, 2001 7:31 AM
Subject: recursion questions


> I am having a problem understanding how to build some JavaScript for an
> exandable/collapsible list similar to a directory tree.  If anybody can
help
> it would be greatly appreciated.  I could include what I have been trying
> XSL-wise but it would probably be more distractive to the end goal.  I
> cannot figure out how to build a recursive template to handle the
following
> XML (the desired output follows):
>
> <section role="level1" folder="root" label="Test">
>     <page id="1"/>
>    <section role="level2" folder="XSLXML" label="XSL/XML">
>         <page id="2"/>
>         <section role="level3" folder="XML" label="XML">
>             <page id="3"/>
>             <page id="4"/>
>        </section>
>        <section role="level3" folder="XSL" label="XSL">
>             <page id="5"/>
>              <page id="6"/
>        </section>
>    </section>
>    <section role="level2" folder="JSDHTMLCSS" label="JS/DHTML/CSS">
>       <section role="level3" folder="JS" label="JS">
>        </section>
>       <section role="level3" folder="DHTML" label="DHTML">
>       </section>
>       <section role="level3" folder="CSS" label="CSS">
>       </section>
>    </section>
> </section>
>
>
>
>
> ============================================================
> DESIRED OUTPUT
> -------------------------------------
>   root = new List(true, width, height, bgColor);
>   root.setFont("<FONT FACE='Arial,Helvetica' SIZE=-1'><B>","</B></FONT>");
>     root.addItem("page id=1");
>     XSLXML = new List(true, width, height, "#EEEEEE");
>     XSLXML.onexpand = colorize;
>     XSLXML.setFont("<FONT FACE='Arial,Helvetica' SIZE=-1'>","</FONT>");
>       XSLXML.addItem("page id=2");
>
>       XML = new List(false, width, height, bgColor);
>       XML.onexpand = colorize;
>       XML.setFont("<FONT FACE='Arial,Helvetica' SIZE=-1'>","</FONT>");
>       XML.addItem("page id=3");
>       XML.addItem("page id=4");
>
>     XSLXML.addList(XML, "XML");
>
>       XSL = new List(false, width, height, bgColor);
>       XSL.onexpand = colorize;
>       XSL.setFont("<FONT FACE='Arial,Helvetica' SIZE=-1'>","</FONT>");
>       XSL.addItem("page id=5");
>       XSL.addItem("page id=6");
> XSLXML.addList(XSL, "XSL");
>
>   root.addList(XSLXML, "XML/XSL");
>
>     JSDHTMLCSS = new List(true, width, height, "#EEEEEE");
>     JSDHTMLCSS.onexpand = colorize;
>     JSDHTMLCSS.setFont("<FONT FACE='Arial,Helvetica'
SIZE=-1'>","</FONT>");
>
>       JS = new List(false, width, height, bgColor);
>       JS.onexpand = colorize;
>       JS.setFont("<FONT FACE='Arial,Helvetica' SIZE=-1'>","</FONT>");
>       JS.addItem("Some JS stuff");
>       JS.addItem("Some more JS stuff");
>
>     JSDHTMLCSS.addList(JS, "JS");
>
>       DHTML = new List(false, width, height, bgColor);
>       DHTML.onexpand = colorize;
>       DHTML.setFont("<FONT FACE='Arial,Helvetica' SIZE=-1'>","</FONT>");
>       DHTML.addItem("Some DHTML stuff");
>       DHTML.addItem("Some more DHTML stuff");
>
>     JSDHTMLCSS.addList(DHTML, "DHTML");
>
>       CSS = new List(false, width, height, bgColor);
>       CSS.onexpand = colorize;
>       CSS.setFont("<FONT FACE='Arial,Helvetica' SIZE=-1'>","</FONT>");
>       CSS.addItem("Some CSS stuff");
>       CSS.addItem("Some more CSS stuff");
>
>     JSDHTMLCSS.addList(CSS, "CSS");
>
>   root.addList(JSDHTMLCSS, "JS/DHTML/CSS");
>
>   root.build(width/8,40);
>


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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.