|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: combine node values
edwin colaco wrote:
The result I get with this XSL template is Col1 Col2 Col3 It seems you hit a standard problem called "grouping", in your case by the value of EEE/@name. You can inform yourself about background and solutions in the XSL FAQ http://www.dpawson.co.uk/ or at Jeni Tennisons site http://www.jenitennison.com/xslt/grouping/index.html The standard technique is usually called Muenchean Grouping (after the inventor). Define a key <xsl:key name="eee-name-group" match="EEE" use="@name"/> This key defines the groups. In the for-each, check whether the element iss the first of the group as selected by the key. Use the key again to get all EEE elements grouped by their name to accumulate the values you need: <xsl:for-each select="/AAA/BBB/CCC/DDD/EEE[generate-id()=generate-id(key('eee-name-group',@name)[1])]">
<xsl:variable name="nodes" select="key('eee-name-group',@name)"/>
<xsl:variable name="ct" select="count($nodes/FFF/GGG)"/>
<xsl:variable name="okct" select="count($nodes/FFF/GGG[status='ok'])"/>
<xsl:variable name="failct" select="count($nodes/FFF/GGG[status='fail'])"/>
<xsl:variable name="successRate" select="((($ct)-($failct)) div ($ct))"/>
...
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








