954,517 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Recursion through specific Nodes

Since it's been about three years since I had to write any XSLT, I'd like some assistance with the code below.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  version="2.0">
<xsl:output method="text"/>
<xsl:template match="/">

<xsl:for-each select="/WatchConfig/ProcessList/Process/Node">
<xsl:if test="Plugin = 'PWScript'">
<xsl:text>
</xsl:text>
<xsl:value-of select="Config" disable-output-escaping="yes" />
<xsl:text>
************************************************************************
</xsl:text>
</xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>


The code above works fine. It outputs the value of the Config element, a child of /WatchConfig/ProcessList/Process/Node, when the "Plugin" sibling value equals "PWScript". In other words, Node contains Config and Plugin, and when Plugin = PWScript, output the value of Config. So far so good.

However, sometimes the Node element contains another Node Element, and I want to perform the same operation on that Node. And so on, deeper and deeper:

/WatchConfig/ProcessList/Process/Node
/WatchConfig/ProcessList/Process/Node/Node
/WatchConfig/ProcessList/Process/Node/Node/Node

I suspect I need to have an IF for "Node" and then call a function recursively.

I've forgotten how. :)

Thanks

tgreer
Made Her Cry
Team Colleague
2,118 posts since Dec 2004
Reputation Points: 227
Solved Threads: 37
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: