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

  • Home
  • SEARCH
  • 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 7004939
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:15:49+00:00 2026-05-27T21:15:49+00:00

I am using a recursive template that searches for some specific elements like this:

  • 0

I am using a recursive template that searches for some specific elements like this:

<xsl:template name="GetProdDependency">
    <xsl:param name="TechProd"></xsl:param>
    <xsl:param name="BeatenPath"></xsl:param>
    <xsl:variable name="TechProdArch" select="$TechProd/pro:own_slot_value[pro:slot_reference='technology_product_architecture']/pro:value"></xsl:variable>
    <xsl:variable name="TechProdArchNode" select="/node()/pro:simple_instance[pro:name=$TechProdArch]"></xsl:variable>
    <xsl:variable name="TechProdCompList" select="$TechProdArchNode/pro:own_slot_value[pro:slot_reference='contained_techProd_components']/pro:value"/>
    <xsl:for-each select="$TechProdCompList">
        <xsl:variable name="TechProdAsRole" select="/node()/pro:simple_instance[pro:name=current()]/pro:own_slot_value[pro:slot_reference='technology_product_as_role']/pro:value"/>
        <xsl:variable name="TechProdRole" select="/node()/pro:simple_instance[pro:name=$TechProdAsRole]/pro:own_slot_value[pro:slot_reference='role_for_technology_provider']/pro:value"/>
        <xsl:variable name="DepTechProd" select="/node()/pro:simple_instance[pro:name=$TechProdRole]"/>
        <!-- Check for beaten Path -->
        <!-- if $DepTechProd/pro:own_slot_value[pro:slot_reference='name']/pro:value in BeatenPath -->
        <xsl:if test="not($BeatenPath[string(.)=string($DepTechProd/pro:own_slot_value[pro:slot_reference='name']/pro:value)])"> 
            <!-- Do the recursion here! -->
            <!--<xsl:value-of select="$DepTechProd/pro:own_slot_value[pro:slot_reference='name']/pro:value"/> (type: <xsl:value-of select="$DepTechProd/pro:type"/> and Class: <xsl:value-of select="$DepTechProd/pro:name"/>)-->
            <!--<xsl:value-of select="$DepTechProd/pro:own_slot_value[pro:slot_reference='name']/pro:value"/>-->
            <xsl:value-of select="$DepTechProd"/>
            <xsl:call-template name="GetProdDependency">
                <xsl:with-param name="TechProd" select="$DepTechProd"></xsl:with-param>
                <xsl:with-param name="BeatenPath" select="$TechProd|$DepTechProd/pro:own_slot_value[pro:slot_reference='name']/pro:value"></xsl:with-param>
                <xsl:with-param name="Rev" select="$Rev + 1"></xsl:with-param>
            </xsl:call-template>
        </xsl:if>
    </xsl:for-each>
</xsl:template> 

This is working fine in the searching etc.

But when I get the result in the original caller, I was expecting to get a list of nodes from the calling.

I call it like:

<xsl:variable name="DelPlist">
<xsl:call-template name="GetProdDependency">
    <xsl:with-param name="TechProd" select="$TechProd"></xsl:with-param>
    <xsl:with-param name="BeatenPath" select="$TechProd/pro:own_slot_value[pro:slot_reference='name']/pro:value"></xsl:with-param>
    <xsl:with-param name="Rev" select="1"></xsl:with-param>
</xsl:call-template>
</xsl:variable>

And I was expecting to get a list of nodes that I can iterate through with <xsl:for-each>. But If I check for the count($DelPlist), I get 1 as result and I can not iterate.

Can somebody help?

  • 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-27T21:15:50+00:00Added an answer on May 27, 2026 at 9:15 pm

    You must specify the type of the result of the template in its as attribute.

    If unspecified, the type is document-node() and then in order to iterate through the result, you need to get the children of the result.

    Solution: Specify the return type of the template with an as attribute.

    Here is a complete example:

    <xsl:stylesheet version="2.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:output omit-xml-declaration="yes" indent="yes"/>
    
     <xsl:template match="/">
         <xsl:variable name="vNodes" as="element()*">
          <xsl:call-template name="genNodes"/>
         </xsl:variable>
    
         <xsl:for-each select="$vNodes">
          <xsl:value-of select="concat('&#xA;', position(), ': ')"/>
          <xsl:copy-of select="."/>
         </xsl:for-each>
     </xsl:template>
    
     <xsl:template name="genNodes" as="element()*">
      <a/>
      <b/>
      <c/>
     </xsl:template>
    </xsl:stylesheet>
    

    when this transformation is applied on any XML document (not used), the wanted, correct result is produced:

    1: <a/>
    2: <b/>
    3: <c/>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a compile-time recursive type that looks somewhat like this: template <typename DataType,
I am trying to render the dictionary content using Django template like this for
Consider this condition that exists in a template that is called recursively: <xsl:if test=$i
I have a basic text template engine that uses a syntax like this: foo
Using LINQ I can find matching elements between two collections like this: var alpha
Let's say I have an XML file that looks like this: <a id=x> <b>
Can some one explain the below, rather complex recursive generic template usage? public abstract
Given a template like template<int dim> class Point { ... }; this template can
I'm using a recursive tree of hashmaps, specifically Hashmap map where Object is a
In the code below I am using a recursive CTE(Common Table Expression) in SQL

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.