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

Display Tree Nodes Incrementally based on ID.

Subject: Display Tree Nodes Incrementally based on ID.
From: "Adam J Knight" <adam@xxxxxxxxxxxxxxxxx>
Date: Mon, 14 Feb 2005 21:02:09 +1000
display tree
Hi all,

Still laboring over this style sheet. I have started reading up on axis'

XML STRUCTURE:
<?xml version="1.0"?>
<tree>
  <tree_node id="7" value="Test">
    <tree_node id="8" value="Test Sub"/>
    <tree_node id="9" value="Test Sub One">
      <tree_node id="10" value="Test Sub Two">
        <tree_node id="11" value="Test Sub Three"/>
             <tree_node id="12" value="Test Sub Four"/>
        </tree_node>
      </tree_node>
    </tree_node>
  </tree_node>
</tree>

I want to display children and ancestor node of tree branch incrementally.

1) If node with id=7 is selected, it childrens are displayed.
2) If node with 10 is selected, Nodes with id 10,9,8,7 are display. Node 
With id=12 is not.

The template below appears to go some way to achieving this, however it
displays all nodes at once.

Would appreciate any help achieving my desired result.    

<xsl:template match="tree_node">
      
  <xsl:if test="parent::tree or ancestor::tree_node[@id=$id]">
    <table width="100%">
      <tr>
	  <td align="right" width="{count(ancestor-or-self::*) * 10}">
          <a href="{$url}&amp;node={@id}">+</a>
        </td>
	  <td>
	    <xsl:value-of select="@value"/>
	  </td>
	</tr>
    </table> 
    <xsl:apply-templates/> 
  </xsl:if>
	  
  </xsl:template>

Cheers, 
Adam 

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.