I'm doing something similar (almost done!) but all in the client side,
using Javascript (Sarissa) . My structure is a little bit more
complicated and i have now 4 or 5 diferent XSLT to take care of it.
But from the beggining i choose to clearly separate the "treatment" of
the tree from the display, so when a user clicks a link i have allways
at least 2 XSLT to invoke, the first determines what are the brenches
to show and the second to do the html rendering.
On Fri, 11 Feb 2005 09:21:10 +1000, Adam J Knight
<adam(_at_)brightidea(_dot_)com(_dot_)au> wrote:
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}&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>
--~--
--~------------------------------------------------------------------
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>
--~--