I have an XSLT with recursion and I call the recursion within a for-each loop
<xsl:for-each select="$ChildList">
<!-- Get the new elNodeList here and recurse -->
<xsl:variable name="inp" select="current()"></xsl:variable>
<xsl:variable name="NewNode" select="/node()/pro:simple_instance[pro:name=$inp]"></xsl:variable>
<xsl:variable name="uniqueNode" select="$NewNode/pro:name except ($BeatenPath)"></xsl:variable>
<xsl:if test="count($uniqueNode) > 0">
<xsl:call-template name="Recurse2Find">
<xsl:with-param name="AppNode" select="$AppNode"></xsl:with-param>
<xsl:with-param name="elNode" select="$NewNode"></xsl:with-param>
<xsl:with-param name="thisProduct" select="$thisProduct"></xsl:with-param>
<xsl:with-param name="BeatenPath" select="$BeatenPath|$NewNode/pro:name"></xsl:with-param>
<xsl:with-param name="rev" select="$rev+1"></xsl:with-param>
<xsl:with-param name="Found" select="0"></xsl:with-param>
</xsl:call-template>
</xsl:if>
</xsl:for-each>
I am basically searching for something in a graph and I go down one level of the graph in each recursion while I follow different legs of the graph in each iteration in the for-each loop.
If I find the item I am searchin for in any of the leg, I wish to stop searching further for that root.
I can return a value from the call-template, but do not know how to implement it and put it as a parameter further. The parameter Found in the template will play otherwise. If I can update the value of the parameter from the earlier recursion, it will help me. But how can I do it?
EDIT:
I am adding some XML elements that build up the source XML here:
<simple_instance>
<name>KB_249702_Class31</name>
<type>Technology_Build_Architecture</type>
<own_slot_value>
<slot_reference>contained_architecture_components</slot_reference>
<value value_type="simple_instance">KB_249702_Class32</value>
<value value_type="simple_instance">KB_181699_Class96</value>
<value value_type="simple_instance">KB_181699_Class97</value>
<value value_type="simple_instance">KB_692833_Class51</value>
<value value_type="simple_instance">KB_692833_Class52</value>
</own_slot_value>
<own_slot_value>
<slot_reference>contained_provider_architecture_relations</slot_reference>
<value value_type="simple_instance">KB_181699_Class98</value>
<value value_type="simple_instance">KB_692833_Class54</value>
<value value_type="simple_instance">KB_692833_Class55</value>
</own_slot_value>
<own_slot_value>
<slot_reference>describes_technology_provider</slot_reference>
<value value_type="simple_instance">KB_249702_Class30</value>
</own_slot_value>
<own_slot_value>
<slot_reference>name</slot_reference>
<value value_type="string">HHS Modernization Arch::Product_Architecture</value>
</own_slot_value>
</simple_instance>
I am looking for some key like KB_249702_Class30 and I start from some root. The root is an element like this with <type>Application_Provider</type> and look at all the <own_slot_value> where I get <value value_type="simple_instance"> and pick up the value. If I do not find, I go to the element with <name>..</name> with the value. I continue the search in this manner.
Store the value of Recurse2Find template in a variable RecurseResult
EDIT:
Note: Since I have less time, haven’t tested this.
Follow this steps for implementing:-
Step 1: Declare a Param variable with dummy value on top
Step 2: After storing the value in RecurseResult variable
Step 3: Pass the RecurseResult variable value to one more call template ParamUpdate for updating the param variable rResult.
Step 4: Call template will update the param variable as follows.
I feel this should work. Try this and let me know.