[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] XSL problem using sum() function
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> ....
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|