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

Re: Grouping & Counting Attribures

Subject: Re: Grouping & Counting Attribures
From: David Carlisle <davidc@xxxxxxxxx>
Date: Mon, 2 Mar 2009 23:42:01 GMT
Re:  Grouping & Counting Attribures
> ??? why didn't this need a [1] near end to get first occurance ??? 

you would in xslt2 (or get an error if you passed two nodes to
generate-id) but in xslt 1 (or xslt2 in bbackwards compat mode)
string functions have a "first node" behaviour, they silently discard
all but the first node passed to them, so generate-id(foo) is the same
as generate-id((foo)[1]) in xslt 1.

In xslt2 though you wouldn't do this at all, you'd use for-each-group.


>   <xsl:variable name="findings" select=key('audits', @AuditName)/>
not well formed.


> ### above line does not work, was meant to go with  above. ###
in what way doesn't it work? It works for me 9as in produces te output
you say you want)

> ### this states what I am trying to do, but I know syntax is wrong ###

actually not, without the line above (which uses correct syntax) I
probably wouldn't have guessed what was intended here.

> ### cannot select on the 2D list returned by key ###
Not sure what you mean here.

If I make your xsl well formed and change the 'InReview' test to use the
syntax you used for  'ActionPlan' I get 

something that appears to match



> Audit  # Rows  ActionPlan  InReview ..........
> CashboxII 2      1           1
> SPN       2      2           0


<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 

<xsl:output method="html"/>

<xsl:key name="audits" match="Row" use="@AuditName" />
<xsl:template match="/dsQueryResponse/Rows">
  <table>
    <tr><th>AUDIT</th><th># Rows</th>
    	<th># ActionPlan</th><th># InReview</th>
    	<th># FollowUp</th><th># Closed</th>
    </tr>
    <xsl:apply-templates
      select="*[@AuditName and
                generate-id(.)=generate-id(key('audits', @AuditName))]" />
  </table>
</xsl:template>

<xsl:template match="*[@AuditName]">
  <xsl:variable name="findings" select="key('audits', @AuditName)"/>
  <tr>
    <td><xsl:value-of select="@AuditName" /></td>
    <td><xsl:value-of select="count(key('audits', @AuditName))" /></td>
    <td><xsl:value-of select="count($findings[@State='ActionPlan'])" /></td>
    <td><xsl:value-of select="count($findings[@State='InReview'])" /></td>
      </tr>
</xsl:template>

</xsl:stylesheet>


$ saxon ds.xml ds.xsl

<table>
   <tr>
      <th>AUDIT</th>
      <th># Rows</th>
      <th># ActionPlan</th>
      <th># InReview</th>
      <th># FollowUp</th>
      <th># Closed</th>
   </tr>
   <tr>
      <td>Cashbox II</td>
      <td>2</td>
      <td>1</td>
      <td>1</td>
   </tr>
   <tr>
      <td>SNP</td>
      <td>2</td>
      <td>2</td>
      <td>0</td>
   </tr>
</table>


David



________________________________________________________________________
The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.

This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs. 
________________________________________________________________________

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-2011 All Rights Reserved.