[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

XSL problem using sum() function

Subject: XSL problem using sum() function
From: Christopher Hansen <chansen1@xxxxxxxxx>
Date: Thu, 18 Nov 2004 12:28:40 -0500
christopher hansen
Im trying to get the sum of all salaries for company:BG (see XML
below).  Im using translate to remove the '$' and ',' from the dollar
amounts and then, trying to sum them up.  But i get the error that it
cannot convert String to NodeList.  I've tried some other workarounds
but i just cant seem to get it.   Any ideas?
Thanks
Chris


The XSL:

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">

        <xsl:output method="html"/>

        <xsl:variable name="workssection" select="document('works.xml')" />
        <xsl:variable name="empsection" select="document('employees.xml')" />

        <xsl:template match="/">
        <xsl:for-each select="$workssection//works-for/" >
          <xsl:if test ="company-name = 'BG'" >
            <xsl:variable name="trans" select="translate(salary,'$,','')" />
            <p><xsl:value-of select="sum($trans)" /></p>
          </xsl:if>
        </xsl:for-each>

        </xsl:template>
</xsl:stylesheet>



A portion of the XML file:
<works>
      <works-for>
            <emp-name>John Doe</emp-name>
            <company-name>BG</company-name>
            <company-city>Ames</company-city>
            <salary>$70,000</salary>
      </works-for>

      <works-for>
            <emp-name>Margaret Thatcher</emp-name>
            <company-name>BG</company-name>
            <company-city>London</company-city>
            <salary>$7,000,000</salary>
      </works-for>
      ....

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.