xsl-list
[Top] [All Lists]

Expandeable Tree!

2005-02-10 16:21:10
Hi all,

First time posting, so I hope I am doing ok.

I have a xml document that gets generated from a database (MySql).
<?xml version="1.0"?>
<tree>
  <tree_node id="7" depth="0" parent="0" value="Test">
    <tree_node id="8" depth="1" parent="7" value="Test Sub"/>
    <tree_node id="9" depth="1" parent="7" value="Test Sub One">
      <tree_node id="10" depth="2" parent="9" value="Test Sub Two"/>
    </tree_node>
  </tree_node>
</tree>

I am seeking to create a similar control to the one seen here:
http://www.15seconds.com/issue/010921.htm 

However all xsl processing is done server side (Using PHP 4 XSLT Processor).
Default view is all level (depth) 0 nodes displayed. A user clicks a html
link that sends the id of the node clicked to the xsl file as a parameter
and all children nodes are displayed. If depth is greater than one, all
ancestor nodes will need to be displayed also.

Here is the beginning of my stylesheet. 

<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.1"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

    <xsl:param name="css"/>
    <xsl:param name="c_node"/>
    <xsl:param name="url"/>

    <xsl:output method="html" indent="yes"/>

    <xsl:template match="tree">
        <table class="{$css}" align="center">
            <xsl:apply-templates /> 
        </table>
    </xsl:template>

    <xsl:template match="//tree_node">
        <tr>
            <td width="{(@depth + 1) * 20}" align="right">
                <a href="{$url}&amp;node={(_at_)id}">+</a>
            </td>
            <td>
                <xsl:value-of select="@value"/>
            </td>
        </tr>
      <xsl:apply-templates select="*[descendant-or-self::*/@id=$c_node]"/>
 
    </xsl:template>
  
</xsl:stylesheet>

I am only acquainted with xsl, so I would sure appreciate any suggestions on
how to do this. I can?t get past displaying the level (depth) 0 nodes, even
when I click the appropriate link.

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>