Jump to content

Totalize nodes attibutes


sgubert

Recommended Posts

Hi,I have a little problem that I don't know how to resolve.I want to totalize some nodes. I'll give an example:

<CATEGORIES>	<CATEGORY ID="CAT1">		<ITEM VALUE="1"/>		<ITEM VALUE="1"/>		<ITEM VALUE="1"/>		<ITEM VALUE="1"/>	</CATEGORY>	<CATEGORY ID="CAT2">		<ITEM VALUE="2"/>		<ITEM VALUE="2"/>		<ITEM VALUE="2"/>		<ITEM VALUE="2"/>	</CATEGORY>	<CATEGORY ID="CAT3">		<ITEM VALUE="3"/>		<ITEM VALUE="3"/>		<ITEM VALUE="3"/>		<ITEM VALUE="3"/>	</CATEGORY><CATEGORIES>

I want to totalize the categories with ID CAT1, CAT2 e CAT3 separately. CAT1=4 CAT2=8 and CAT3=12.After, I would like to get the total sum of all Categories, for example, 24.I hope someone can help me,ThanksSamuel

Link to comment
Share on other sites

Bar bones of a solution is as follows:

<xsl:template match="CATEGORIES">  <xsl:apply-templates/>  <xsl:value-of select="sum(CATEGORY/ITEM/@VALUE)"/></xsl:template><xsl:template match="CATEGORY">  <xsl:value-of select="sum(ITEM/@VALUE)"/></xsl:template>

Depending on the exact result format you want to add elements and text structuring the result.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...