XSL : how using sum with a comma delimited list

O

ouioui

Hi,

I need to use the xsl sum function like that :

<xsl:value-of select="sum(CompteRendu/Compte/@number)" />

My xml source contains number with comma like that :

<Compte number=447,68" />
<Compte number="11904,66" />

How can i use the sum function with a comma delimited list?
 
M

Mukul Gandhi

Please try this XSL...

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xalan="http://xml.apache.org/xalan">

<xsl:eek:utput method="text" />

<xsl:template match="/">
<xsl:variable name="rtf">
<xsl:for-each select="CompteRendu/Compte/@number">
<num>
<xsl:value-of select="translate(.,',','')" />
</num>
</xsl:for-each>
</xsl:variable>
<xsl:value-of select="sum(xalan:nodeset($rtf)/num)" />
</xsl:template>

</xsl:stylesheet>

The above XSL uses nodeset extension function...

Regards,
Mukul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top