[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

combine node values

Subject: combine node values
From: edwin colaco <Edwin.Colaco@xxxxxxx>
Date: Thu, 19 Sep 2002 13:22:42 -0400
xsl combine nodes
My xml data file is as follows:
<AAA>
  <BBB>
    <CCC>
      <DDD acount=3 bcount=1 ccount=2>
	<EEE name="aaa">
      	   <FFF>
		<GGG id="1">
			<status>ok</>
		</GGG>

		<GGG id="2">
			<status>ok</>
		</GGG>

		<GGG id="3">
			<status>fail</>
		</GGG>
	
	  </FFF>
	</EEE>
	
	<EEE name="bbb">
	   <FFF>
		<GGG id="1">
			<status>ok</>
		</GGG>

		<GGG id="2">
			<status>fail</>
		</GGG>

		<GGG id="3">
			<status>ok</>
		</GGG>
	   </FFF>
	</EEE>
     </DDD>
   </CCC>

   <CCC>
     <DDD acount=3 bcount=1 ccount=2>
	<EEE name="aaa">
	   <FFF>
		<GGG id="1">
			<status>ok</>
		</GGG>
	
		<GGG id="2">
			<status>ok</>
		</GGG>

		<GGG id="3">
			<status>ok</>
		</GGG>
    	   </FFF>
	</EEE>
	<EEE name="bbb">
	    <FFF>
		<GGG id="1">
			<status>ok</>
		</GGG>
		<GGG id="2">
			<status>fail</>
		</GGG>

		<GGG id="3">
			<status>ok</>
		</GGG>
    	    </FFF>
	</EEE>
      </DDD>
   </CCC>
  </BBB>
</AAA>

The xsl stylesheet contains the following template rule:

<xsl:template name="Test">
   <P><B>Summary:</B></P>
	<table border="1" width="100%">
		<tr bgcolor="#666699">
			<th align="left"><font color="white">Col1</font></th>
			<th align="left"><font color="white">Col2</font></th>
			<th align="left"><font color="white">Col3</font></th>
		</tr>
		<xsl:for-each select="/AAA/BBB/CCC/DDD/EEE">
			<xsl:variable name="ct" select="count(FFF/GGG)"/>
			<xsl:variable name="okct" select="count(FFF/GGG[status='ok'])"/>

			<xsl:variable name="failct" select="count(FFF/GGG[status='fail'])"/>
			<xsl:variable name="successRate" select="((($ct)-($failct)) div ($ct))"/>
		<tr>
			<td><a href="#{@name}"><xsl:value-of select="@name"/></a></td>
			<td><xsl:value-of select="$ct"/></td><td><xsl:value-of select="$okct"/>
			</td><td><xsl:value-of select="$failct"/></td>
			<td><xsl:value-of select="format-number($successRate,'#00.00%')"/></td>
		</tr>
		</xsl:for-each>
	</table>
</xsl:template>

The result I get with this XSL template is 
Col1		Col2		Col3
aaa		2		1
bbb		2		1
aaa		3		0
bbb		2		1

I would like to get the following result instead
Col1		Col2		Col3
aaa		5		1
bbb		4		2

Would appreciate the help..Thanks

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.