XSL : how using sum with a comma delimited list

Discussion in 'XML' started by ouioui, Sep 21, 2004.

  1. ouioui

    ouioui Guest

    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?
     
    ouioui, Sep 21, 2004
    #1
    1. Advertising

  2. ouioui

    Mukul Gandhi Guest

    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

    (ouioui) wrote in message news:<>...
    > 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?
     
    Mukul Gandhi, Sep 23, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Yama

    Comma Delimited

    Yama, Dec 15, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    401
    Ken Cox [Microsoft MVP]
    Dec 16, 2003
  2. Roy Smith

    Building unique comma-delimited list?

    Roy Smith, Jan 5, 2005, in forum: Python
    Replies:
    5
    Views:
    449
    Bengt Richter
    Jan 6, 2005
  3. RyanL
    Replies:
    6
    Views:
    690
    Paul McGuire
    Aug 28, 2007
  4. Christine Forber
    Replies:
    4
    Views:
    598
    Christine Forber
    Aug 27, 2005
  5. Replies:
    5
    Views:
    229
Loading...

Share This Page