Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XSL: Sum only elements that meet criteria

Status
Not open for further replies.

wurld2

Technical User
Jan 7, 2004
3
US
Hello everyone.

I'm trying to sum the value of the element 'count' where the element 'rulesetVersion' meets a certain criteria (equals parameter 'version')

XML:
<?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;yes&quot;?>
<fenx-stats end-date=&quot;2003-11-01T23:59:58-05:00&quot; start-date=&quot;2003-11-01T00:00:00-05:00&quot;>
<pattern-count>
<check>
<type>tec</type>
<param>10080</param>
<result>true</result>
</check>
<rulesetVersion>1.0.0.0.0</rulesetVersion>
<count>5760</count>
</pattern-count>

<pattern-count>
<check>
<type>tec</type>
<param>10080</param>
<result>true</result>
</check>
<rulesetVersion>2.0.0.0.0</rulesetVersion>
<count>2374</count>
</pattern-count>
<pattern-count>
<check>
<type>tec</type>
<param>10080</param>
<result>true</result>
</check>
<rulesetVersion>2.1.0.0.0</rulesetVersion>
<count>1</count>
</pattern-count>
<pattern-count>
<check>
<type>regc</type>
<param>regc param</param>
<result>true</result>
</check>
<rulesetVersion>1.0.0.0.0</rulesetVersion>
<count>2300</count>
</pattern-count>

</fenx-stats>


XSL:
<?xml version=&quot;1.0&quot;?>
<xsl:stylesheet xmlns:xsl=&quot; version=&quot;1.0&quot;>
<xsl:param name=&quot;version&quot;/>
<xsl:template match=&quot;/fenx-stats&quot;>
<HTML>
<BODY>
<xsl:for-each select=&quot;pattern-count&quot;>
<xsl:if test=&quot;rulesetVersion = $version&quot;>
<xsl:for-each select=&quot;check&quot;>
<xsl:value-of select=&quot;type&quot;/><br/>
<xsl:value-of select=&quot;param&quot;/><br/>
<xsl:value-of select=&quot;result&quot;/><br/>
</xsl:for-each>
<xsl:value-of select=&quot;rulesetVersion&quot;/><br/>
<xsl:value-of select=&quot;count&quot;/>
</xsl:if>
</xsl:for-each>
</BODY>
</HTML>
</xsl:template>
</xsl:stylesheet>

This displays the desired nodes, specifically, if the incoming parameter 'version' is '1.0.0.0.0' the first and last are shown. As stated above, I need a total for the 'count' element for the displayed nodes to be shown at the top of the page (with a version of 1.0.0.0.0, count = 8060).

Thanks for looking,
Chris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top