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

Expandeable Tree!

Subject: Expandeable Tree!
From: "Adam J Knight" <adam@xxxxxxxxxxxxxxxxx>
Date: Fri, 11 Feb 2005 09:21:10 +1000
html xsl tree table
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={@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 cant get past displaying the level (depth) 0 nodes, even
when I click the appropriate link.

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.