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

Walking a tree

Subject: Walking a tree
From: Marcus Andersson <marcus@xxxxxxxxxx>
Date: Thu, 28 Oct 2004 22:48:53 +0200
walking a tree
I'm trying to walk a tree with the following structure (more or less):

<node>
  <node name="node1">
    <leaf name="leaf1"/>
    <leaf name="leaf2"/>
  </node>
  <node name="node2">
    <node name="node22">
      <leaf name="leaf221"/>
      <leaf name="leaf222"/>
    </node>
    <node name="node23">
      <leaf name="leaf231"/>
      <leaf name="leaf232"/>
    </node>
    <node name="node24">
      <leaf name="leaf241"/>
      <leaf name="leaf242"/>
    </node>
  </node>
</node>

Then I want to render a graphical tree based on this and on a selected node (for example, if I have clicked on node24 I want the tree to be unfolded downto that node including it's children. I don't want node23 and node22 to be unfolded and neither node1).

I have some almost working code to render this except that a test isn't working so when I click on node24 then node22 and node23 get unfolded as well.

  <xsl:template name="pageNav">
    <xsl:param name="targetNode"/>
    <xsl:param name="currentNode"/>
      <xsl:for-each select="$currentNode/node|$currentNode/leaf">
	... lots of presentation code ...

            <!-- I guess it's this test that should be modified -->
              <xsl:if test=". = $targetNode/ancestor-or-self::node">
                <xsl:call-template name="pageNav">
                  <xsl:with-param name="targetNode" select="$targetNode"/>
                  <xsl:with-param name="currentNode" select="."/>
                </xsl:call-template>
              </xsl:if>
      </xsl:for-each>
  </xsl:template>

Any suggestions? Do you need more input? I'm using MSXML3 so node-set() is acceptable (although it shouldn't be needed)

/Marcus

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.