Subject: [xsl] XSL problem using sum() function From: Christopher Hansen <chansen1@xxxxxxxxx> Date: Thu, 18 Nov 2004 12:28:40 -0500 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] XSLT Generated Text, Derek Basch | Thread | RE: [xsl] XSL problem using sum() f, Michael Kay |
RE: [xsl] RE: [Bu posta banka disin, JBryant | Date | RE: [xsl] Re: Problem passing node-, Michael Kay |
Month |