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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T11:43:08+00:00 2026-06-05T11:43:08+00:00

I have the following XML structure: <example> <data> <numberGer>3,40</numberGer> </data> <data> <numberGer>7,40</numberGer> </data> <data>

  • 0

I have the following XML structure:

  <example>
    <data>
       <numberGer>3,40</numberGer>
    </data>
    <data>
      <numberGer>7,40</numberGer>
    </data>
    <data>
       <numberGer>17,40</numberGer>
    </data>
  </example>

I need the sum of all the “numberGer” nodes. The formatting of the number is a problem. Because of the use of “,” the function “sum” produces a error. So something like sum(//numberGer) does not work. I can use XSLT 2.0 functions.

I think I need to write a recursive template, which takes the computed value and a list of nodes.

Something like:

<xsl:template name="addGerNumbers">
        <xsl:param name="number"/>
        <xsl:param name="nodes"/>
      <xsl:choose>
        <xsl:when test="$nodes">
          <xsl:variable name="recursive_result">
            ...
           <xsl:call-template name="addGerNumbers">
             ...
            </xsl:call-template>
            </xsl:variable>
          <xsl:value-of select="$number + $recursive_result"/>
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="0"/>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:template>

At the end I need a single value as an result.

How to XPath sum() all previous nodes in a XSL for-each loop? Does not work for me, because I need a single number at the end.

  • 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-06-05T11:43:09+00:00Added an answer on June 5, 2026 at 11:43 am

    A single XPath 2.0 expression is enough:

    <xsl:value-of select="sum( for $i in //numberGer return number(translate( $i, ',','.') ) )"/>
    

    The for loop will translate each value to replace commas with dots, then convert them into numbers. It returns a sequence of numbers that you can now sum normally.

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

Sidebar

Related Questions

one more problem. I have following structure of XML: <player> <id>12</id> <name>pl_name</name> <experience> <points>147</points>
I have XML with the following structure, for example <root> <node flag=false/> <node flag=true/>
I have the following Xml structure: <sitemapindex xmlns=http://www.sitemaps.org/schemas/sitemap/0.9> <sitemap> <loc>http://www.example.com/</loc> <lastmod>2011-11-27T08:34:46+00:00</lastmod> </sitemap> <sitemap> <loc>http://www.example.com/123</loc>
I have the following XML structure: <Main> <Node1>Definite</Node1> <Node2>Definite</Node2> <Node3>Definite</Node3> <Node4>Definite</Node4> <Node5>Definite</Node5> <Node6>Definite</Node6> <A>Possible</A>
I have the following XML source structure: <turnovers> <turnover repid=1 amount=500 rate=0.1/> <turnover repid=5
I have the following simplified XML structure: <?xml version="1.0" encoding="UTF-8" ?> <INVOIC02> <IDOC BEGIN="1">
I have an XML Structure like the following: <Tickets> <EventsPoints> <Event ID=23> <PerformanceName>U2</PerformanceName> <EventDate>25/05/2012</EventDate>
I have following object structure, deseralized from XML (WS): <ns2:Category> <ns2:CategoryId>800003</ns2:CategoryId> <ns2:CategoryName>Name1</ns2:CategoryName> <ns2:Categories> <ns2:Category>
I have an XML with following structure: <table name=tblsiccodes> <row> <sSICCode>0888</sSICCode> </row> <row> <sSICCode>0900</sSICCode>
I have an xml file with following structure: <table name=tblcats> <row> <Id>3680</Id> <Industry>Associations</Industry> <ParentId>1810</ParentId>

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.