sum only odd ones : sum « XSLT stylesheet « XML Tutorial

File: Data.xml
<?xml version="1.0" encoding="utf-8"?>
File: Transform.xslt

<?xml version="1.0" encoding="utf-8"?>
    <xsl:template match="/">
      <xsl:for-each select="//number[text() mod 2 = 1]">
        <xsl:value-of select="."/>
    <xsl:when test="position()=last()">
      <xsl:text> = </xsl:text>
      <xsl:text> + </xsl:text>
      <xsl:value-of select="sum(//number[text() mod 2 = 1])"/>


<?xml version="1.0" encoding="UTF-8"?>1 + 3 + 17 + 11 = 32

5.13.1.sum()- Takes a node-set as its argument and returns the sum of the value of each individual node after converting the values to a numeric type if possible.
5.13.2.round the result of sum()
5.13.3.Sum value
5.13.4.sum() sums all numbers in selected nodes.
5.13.5.sum only odd ones