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 6220751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:00:46+00:00 2026-05-24T08:00:46+00:00

I’m looking for an elegant way to return multiple values from one subtemplate. why?

  • 0

I’m looking for an elegant way to return multiple values from one subtemplate.

why? – I have a subtemplate with a recursive loop that returns the max value of a node in an xml. I also need the min value and the total count of the nodes which I can simply get from the same subtemplate. I don’t wonna loop 3 times, not really good for the performance 🙂

Solutions I found so far:

  • Create a string of the 3 values I need and get a substring of them.
  • …

I’m using xsl v1.0

Thanks

  • 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-24T08:00:47+00:00Added an answer on May 24, 2026 at 8:00 am

    It may not be convenient accessing each of many (say hundreds) results presented in a single string.

    This is where the power of XML and XPath can be best seen and utilized: produce an XML tree as the result.

    Here is an example:

    <xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:output omit-xml-declaration="yes" indent="yes"/>
     <xsl:strip-space elements="*"/>
    
     <xsl:template match="/*">
          <xsl:call-template name="sequenceStatistics">
           <xsl:with-param name="pSeq" select="*"/>
          </xsl:call-template>
     </xsl:template>
    
     <xsl:template name="sequenceStatistics">
      <xsl:param name="pSeq"/>
    
      <xsl:variable name="vCount" select="count($pSeq)"/>
    
      <results>
       <count><xsl:value-of select="$vCount"/></count>
        <xsl:for-each select="$pSeq">
         <xsl:sort data-type="number"/>
         <xsl:choose>
           <xsl:when test="position() = 1">
             <min><xsl:value-of select="."/></min>
           </xsl:when>
           <xsl:when test="position() = $vCount">
             <max><xsl:value-of select="."/></max>
           </xsl:when>
         </xsl:choose>
        </xsl:for-each>
      </results>
     </xsl:template>
    </xsl:stylesheet>
    

    When this transformation is applied on the following XML document:

    <nums>
      <num>7</num>
      <num>3</num>
      <num>9</num>
      <num>10</num>
      <num>4</num>
      <num>2</num>
      <num>5</num>
      <num>08</num>
      <num>6</num>
      <num>1</num>
    </nums>
    

    the wanted, correct result is produced:

    <results>
       <count>10</count>
       <min>1</min>
       <max>10</max>
    </results>
    

    Do note:

    1. If the result is in the body of a variable, the variable type is RTF (Result Tree Fragment) and it must be converted to a regular tree using the xxx:node-set() function before the nodes of the result can be accessed individually. There is no such restriction in XPath 2.0 (XSLT 2.0).

    2. As this example shows, there is no need of recursion to produce the maximum and minimum of a sequence — even in XSLT 1.0.

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

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I have a text area in my form which accepts all possible characters from
I'm looking for suggestions for debugging... If you view this site in Firefox or
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
Seemingly simple, but I cannot find anything relevant on the web. What is the

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.