xsl-list
[Top] [All Lists]

Display Tree Nodes Incrementally based on ID.

2005-02-14 04:02:09
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[(_at_)id=$id]">
    <table width="100%">
      <tr>
          <td align="right" width="{count(ancestor-or-self::*) * 10}">
          <a href="{$url}&amp;node={(_at_)id}">+</a>
        </td>
          <td>
            <xsl:value-of select="@value"/>
          </td>
        </tr>
    </table> 
    <xsl:apply-templates/> 
  </xsl:if>
          
  </xsl:template>

Cheers, 
Adam 



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>