XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 13th, 2003, 10:37 AM
munna munna is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 30 munna User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Problem with node-occurence statistics

Hi,
I have an xml document that is similar to this:

<?xml version="1.0" encoding="utf-8"?>
<report>

<group>
<groupid>group1</groupid>
<goalcount>2</goalcount>
<details>
<team>
<teamleader>P.P.</teamleader>
<goal>[2]</goal>
</team>
<team>
<teamleader>T.T.</teamleader>
<goal>[2]</goal>
</team>
</details>
</group>

<group>
<groupid>group2</groupid>
<goalcount>3</goalcount>
<details>
<team>
<teamleader>N.N.</teamleader>
<goal>[3]</goal>
</team>
<team>
<teamleader>P.P.</teamleader>
<goal>[2]</goal>
</team>
<team>
<teamleader>T.T.</teamleader>
<goal>[3]</goal>
</team>
</details>
</group>



<group>
<groupid>group3</groupid>
<goalcount>1</goalcount>
<details>
<team>
<teamleader>T.T.</teamleader>
<goal>[1]</goal>
</team>
<team>
<teamleader>P.P.</teamleader>
<goal>[3]</goal>
</team>
</details>
</group>

</report>

I want to produce a report that will show how many times the same number of goals have been acheived under the same teamleader.
So the result should look something like this:

teamleader goal number of occurences
P.P. 2 2
P.P. 3 1
T.T. 2 1
T.T. 3 1
T.T. 1 1
N.N. 3 1

Please can someone tell me how to do this?

I have got this but it doesn't work:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xslutput
method="html"/>
<xsl:key name="IDs" match="teamleader" use="../goal" />
<xsl:key name="IDs2" match="attribvalue" use="../../teamleader" />
<xsl:template match="/">
<div><table cellpadding="5">


<tr><th>teamleader</th><th>goal</th><th>Number of occurences</th></tr>
<xsl:for-each select="//teamleader">
<xsl:variable name="tmp">
<xsl:value-of select="../goal" />
</xsl:variable>

<xsl:variable name="tmp2">
<xsl:value-of select="." />
</xsl:variable>
<xsl:if test="generate-id(.) = generate-id(key('IDs',$tmp)[1])">
<tr><td><xsl:value-of select="."/></td>
<td><xsl:value-of select="$tmp" /></td>
<td><xsl:value-of select="count(key('IDs',$tmp))"/></td></tr>
</xsl:if>

</xsl:for-each>


</table>
</div>
</xsl:template>


</xsl:stylesheet>

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > Problem with node-occurence statistics


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT