xslt - sum value of element -


i need add number of values​​, depending on content of each item. example.

<links> <test element="32"/> <test element="17"/> <test element="13"/> <test element="11"/> <test element="9"/> <test element="8"/> <test element="7"/> <test element="7"/> </links> 

total element: 8, sum of values ​​of each element: 104, value show this(104).

  <xsl:template match="//x:span[@class='ws-filter-count']">     <xsl:variable name="countproduct" select="normalize-space(translate(text(), '()', ''))" />     <xsl:variable name="sum" select="number(0)"/>     <test element="{$countproduct}" />   </xsl:template> 

this sum:

will done call-template?, recursive, correct?. thanks.

if understood correctly want achieve:

stylesheet

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform">   <xsl:output method="text" version="1.0"/>    <xsl:template match="links">     <xsl:value-of select="sum(test/@element)"/>   </xsl:template> </xsl:stylesheet> 

input

<links>   <test element="32"/>   <test element="17"/>   <test element="13"/>   <test element="11"/>   <test element="9"/>   <test element="8"/>   <test element="7"/>   <test element="7"/> </links> 

output

104 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -