p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

xslt thread: XSLT Sum function Issue


Message #1 by "Steven Egert" <steven.h.egert@a...> on Tue, 24 Jul 2001 23:22:15
Hi Steven

Enclosing the three xml nodes you gave in a root node and running the
xml against the following xslt returned the correct answer.  Perhaps you
had a syntax error??

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output method="xml" version="1.0"/>
	<xsl:template match="/">
		<xsl:value-of select="sum(//OptionVotes)"/>
	</xsl:template>
</xsl:stylesheet>

Regards
Lock Macfarlane

-----Original Message-----
From: Steven Egert [mailto:steven.h.egert@a...] 
Sent: 24 July 2001 23:22
To: P2P_XSLT
Subject: [xslt] XSLT Sum function Issue

I am trying to sum the field OptionVotes from the xml file below.  But I

have not been able to do this successfully. I have tried using the SUM 
function, but I am not getting anywhere.  I am doing this creating a new

field called TotalVotes.  Any suggestions??


<PollOption>
		<PollOptionID><![CDATA[1]]></PollOptionID>
		<OptionText><![CDATA[Yes, it's a high]]></OptionText>
		<OptionVotes><![CDATA[2]]></OptionVotes>
		<CreatedBy/>
		<ModifiedBy/>
		<CreateDate/>
		<ModifyDate/>
	</PollOption>
	<PollOption>
		<PollOptionID><![CDATA[2]]></PollOptionID>
		<OptionText><![CDATA[Yes, but it's a low priority] 
></OptionText>
		<OptionVotes><![CDATA[0]]></OptionVotes>
		<CreatedBy/>
		<ModifiedBy/>
		<CreateDate/>
		<ModifyDate/>
	</PollOption>
	<PollOption>
		<PollOptionID><![CDATA[6]]></PollOptionID>
		<OptionText><![CDATA[No]]></OptionText>
		<OptionVotes><![CDATA[0]]></OptionVotes>
		<CreatedBy/>
		<ModifiedBy/>
		<CreateDate/>
		<ModifyDate/>
	</PollOption>


  Return to Index