Altova Mailing List Archives>Archive Index >xsl-list Archive Home >Recent entries >Thread Prev - [xsl] Problem with filtrate sum >Thread Next - Re: [xsl] Problem with filtrate sum Re: [xsl] Problem with filtrate sumTo: xsl-list@-----.------------.--- Date: 10/1/2009 5:21:00 PM j23 wrote: > <xsl:template match="root-element"> > > <table> > <xsl:variable name="x"> > <xsl:for-each select="Row[position()>=1]"> > <d><xsl:value-of select="translate(Number,'.','')"/></d> > </xsl:for-each> > </xsl:variable> > > <td><xsl:value-of select="sum(exslt:node-set($x)/d) "/></td> > > </table> > </xsl:template> > > </xsl:stylesheet> > > I would like to sum number (without character '.'). It works. > Now I try sum for one name, I make like this but it doesn't work > <xsl:value-of select="sum([Name = 'Joe']exslt:node-set($x)/d) "/> > How can I filtrate sum with using function translate, or key? If it is just for one name then you can simply change the code that sets up the variable e.g. <xsl:variable name="x"> <xsl:for-each select="Row[position()>=1][Name = 'Joe']"> <d><xsl:value-of select="translate(Number,'.','')"/></d> </xsl:for-each> </xsl:variable> then you would simply compute the sum as before <xsl:value-of select="sum(exslt:node-set($x)/d)"/> If you want to compute the sum for several names then you need to store the name when you build your variable e.g. <xsl:variable name="x"> <xsl:for-each select="Row[position()>=1]"> <d> <name><xsl:value-of select="Name"/></name> <value><xsl:value-of select="translate(Number,'.','')"/></value> </d> </xsl:for-each> </xsl:variable> Now you can compute e.g. <xsl:value-of select="sum(exslt:node-set($x)/d[name = 'Joe']/value)"/> -- Martin Honnen http://msmvps.com/blogs/martin_honnen/ --~------------------------------------------------------------------ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/ or e-mail: <mailto:xsl-list-unsubscribe@l...> --~-- | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
