Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6995495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:01:59+00:00 2026-05-27T20:01:59+00:00

I have an XSLT with recursion and I call the recursion within a for-each

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T20:02:00+00:00Added an answer on May 27, 2026 at 8:02 pm

    Store the value of Recurse2Find template in a variable RecurseResult

    <xsl:variable name="RecurseResult">
        <xsl:call-template name="Recurse2Find">
            <!-- Do your stuff -->
        </xsl:call-template>
    </xsl:variable> 
    

    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

    <xsl:param name="rResult" select="0" />
    

    Step 2: After storing the value in RecurseResult variable

      <xsl:variable name="RecurseResult">
         <xsl:call-template name="Recurse2Find">
              <xsl:with-param name="temp" select="$rResult"/>
              <!-- Do your stuff -->
         </xsl:call-template>
      </xsl:variable> 
    
      Note: for the first time, rResult has dummy value.
    

    Step 3: Pass the RecurseResult variable value to one more call template ParamUpdate for updating the param variable rResult.

    <xsl:call-template name="ParamUpdate">
        <xsl:with-param name="temp" select="$RecurseResult"/>
    </xsl:call-template>
    

    Step 4: Call template will update the param variable as follows.

    <xsl:template name="ParamUpdate">
        <xsl:param name="temp" />
        <xsl:param name="rResult" select="$temp"/>
    </xsl:template>
    

    I feel this should work. Try this and let me know.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this XSLT to create rows according to position in for-each: <xsl:for-each select=Campaign>
I have two XSLT variables as given below: <xsl:variable name=staticBaseUrl select='https://www.hello.com/htapi/PrintApp.asmx/getGames?contentId=id_sudoku&uniqueId=123456&pageformat=a4' /> <xsl:variable name=dynamicUrl
I have a xslt stylesheet with multiple xsl:import s and I want to merge
I have an xslt sheet with some text similar to below: <xsl:text>I am some
Lets say I have a xslt stylesheet like the following: <?xml version=1.0 encoding=utf-8?> <xsl:stylesheet
I have XSLT 1.0 code like this: <xsl:key name=enemyItems match=metadata[attributes/metadata_key/@value = 'enemylist'] use=attributes/metadata_refkey/@value/> <xsl:template
I have this XSLT: <xsl:strip-space elements=* /> <xsl:template match=math> <img class=math> <xsl:attribute name=src>http://latex.codecogs.com/gif.latex?<xsl:value-of select=text()
I have this XSLT document : <xsl:stylesheet version=1.0 xmlns:mstns=http://www.w3.org/2001/XMLSchema xmlns=http://www.w3.org/2001/XMLSchema xmlns:xs=http://www.w3.org/2001/XMLSchema xmlns:msdata=urn:schemas-microsoft-com:xml-msdata xmlns:xsl=http://www.w3.org/1999/XSL/Transform> <xsl:output
I have an xslt stylesheet that needs to call a C# XSLT extension function
I have some xslt that uses a c# function to get a string, im

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.