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>
....
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--