|
Subject: [xsl] Halt rendering of nodes based on node id!! From: "Adam J Knight" <adam@xxxxxxxxxxxxxxxxx> Date: Thu, 17 Feb 2005 20:33:06 +1000 |
Hi all,
Hooray!!!
I may have made some progress, I hope!!!
Question:
Given the following xml/xsl files:
How do I stop stylesheet rendering or exclude nodes from rendering once a
particular nodes children are rendered. Ie: If the current node selected is
node with id(10); it, its ancestors and its children are displayed. However,
the children of its children(12,13) are node rendered.
The modification I believe with need to occur here:
<xsl:apply-templates select="//tree_node[parent::tree or
ancestor::tree_node[@id=$id]]"/>
COMPLETE XML FILE:
<tree>
<tree_node id="7" value="Test">
<tree_node id="8" value="Test Sub One"/>
<tree_node id="9" value="Test Sub One">
<tree_node id="10" value="Test Sub Two"/>
<tree_node id="11" value="Test Sub Two">
<tree_node id="12" value="Test Sub Three"/>
<tree_node id="13" value="Test Sub Three"/>
</tree_node>
</tree_node>
</tree_node>
</tree>
COMPLETE XSL FILE:
<?xml version="1.0"?>
<xsl:stylesheet version="1.1"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="css"/>
<xsl:param name="url"/>
<xsl:param name="id"/>
<xsl:output method="html" indent="yes"/>
<xsl:template match="/">
<table cellspacing="0" cellpadding="2" class="{$css}">
<tr>
<td class="ui_tree_bar">
<a href="{$url}&action=add">add</a>
</td>
</tr>
<xsl:apply-templates select="//tree_node[parent::tree or
ancestor::tree_node[@id=$id]]"/>
</table>
</xsl:template>
<xsl:template match="tree_node">
<tr>
<td>
<table width="100%">
<tr>
<td align="right" width="{count(ancestor-or-self::*) * 10}">
<xsl:choose>
<xsl:when test="child::tree_node">
<a href="{$url}&node={@id}">+</a>
</xsl:when>
<xsl:otherwise>
-
</xsl:otherwise>
</xsl:choose>
</td>
<td>
<xsl:value-of select="@value"/>
</td>
<td align="right" width="25%">
<a href="{$url}&action=edit&node={@id}">edit</a>
<a
href="{$url}&action=delete&node={@id}">delete</a>
</td>
</tr>
</table>
</td>
</tr>
<xsl:apply-templates select="child::tree_node[@id = $id]"/>
</xsl:template>
</xsl:stylesheet>
Cheers,
Adam
NB: "Pray as if everything depended upon God and work as if everything
depended upon man."
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| RE: [xsl] XSLT and comma's in XML d, Michael Kay | Thread | Re: [xsl] Halt rendering of nodes , Joris Gillis |
| Re: [xsl] XSLT and comma's in XML d, David Carlisle | Date | Re: [xsl] equivalent for 'while', RQamar |
| Month |