Subject: RE: [xsl] RE: Display children of node with given Id!! From: "Andrew Welch" <ajwelch@xxxxxxxxxxxxxxx> Date: Wed, 16 Feb 2005 11:36:16 -0000 |
> Following on from my previous post. > Thanks to those who replied, it is much appreciated. > This stylesheet matches all nodes that are descended from > node with a given id. > > Two Things: > 1) How do I modify this stylesheet to include the rendering > of all top level tree nodes? Can I do this in the > <xsl:apply-templates select=""/> element. I have tried > <xsl:apply-templates select="parent::tree or //tree_node[@id > = $id]"/>??? > > 2) How do I modify this stylesheet to only display immediate > children(not grandchildren ect) descended from the node with > a given id. In the case node id = 7 , nodes 8, 9 will only be > displayed. Not 10. > > > COMPLETE XML STRUCTURE: > > <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> > </tree_node> > <tree_node id="11" value="Test 2"/> > </tree> For 1) use <xsl:apply-templates select="/tree/tree_node"/> (as I'm assuming your 'top level tree nodes' are <tree_nodes>? Maybe you mean something else?) For 2) use <xsl:apply-templates select="//tree_node[@id = $id]/tree" mode="child_only"/> (note the mode) and then add a moded template that matches <tree_node> but doesn't contain an <xsl:apply-templates/> cheers andrew
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] RE: Display children of node , Adam J Knight | Thread | [xsl] Optimization using keys, António Mota |
Re: [xsl] Bug in Schema for XSLT 2., Dimitre Novatchev | Date | [xsl] Optimization using keys, António Mota |
Month |