I'm trying to walk a tree with the following structure (more or less):
<node>
<node name="node1">
<leaf name="leaf1"/>
<leaf name="leaf2"/>
</node>
<node name="node2">
<node name="node22">
<leaf name="leaf221"/>
<leaf name="leaf222"/>
</node>
<node name="node23">
<leaf name="leaf231"/>
<leaf name="leaf232"/>
</node>
<node name="node24">
<leaf name="leaf241"/>
<leaf name="leaf242"/>
</node>
</node>
</node>
Then I want to render a graphical tree based on this and on a selected node (for example, if I have clicked on
node24 I want the tree to be unfolded downto that node including it's children. I don't want node23 and node22
to be unfolded and neither node1).
I have some almost working code to render this except that a test isn't working so when I click on node24 then
node22 and node23 get unfolded as well.
<xsl:template name="pageNav">
<xsl:param name="targetNode"/>
<xsl:param name="currentNode"/>
<xsl:for-each select="$currentNode/node|$currentNode/leaf">
... lots of presentation code ...
<!-- I guess it's this test that should be modified -->
<xsl:if test=". = $targetNode/ancestor-or-self::node">
<xsl:call-template name="pageNav">
<xsl:with-param name="targetNode" select="$targetNode"/>
<xsl:with-param name="currentNode" select="."/>
</xsl:call-template>
</xsl:if>
</xsl:for-each>
</xsl:template>
Any suggestions? Do you need more input? I'm using MSXML3 so node-set() is acceptable (although it shouldn't
be needed)
/Marcus