|
Subject: Re: [xsl] Grouping & Counting Attribures From: David Carlisle <davidc@xxxxxxxxx> Date: Mon, 2 Mar 2009 23:42:01 GMT |
> ??? 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 |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| [xsl] Grouping & Counting Attribure, Dick Penny | Thread | [xsl] Preceding sibling selction, Senthilukvelaan |
| Re: [xsl] XSLT test condition, David Carlisle | Date | Re: [xsl] XSLT test condition, Senthilukvelaan |
| Month |