Graham (archive)
Usenet Archive
- Joined
- Mar 9, 2000
- Messages
- 112
- Reaction score
- 0
Hi,
I am having trouble getting XSL to count the members of a group. What I am trying to do is group by <objectid.Contactid> and count the number of <activityid>'s for each <objectid.contactid>. My XSL keeps returning zero for the count. The results for the XML/XSLT files below should look like:-
Contact # of Visits Account
johnson, johnny 2 account 1 sub bragg, billy 1 account2
Any help would be greatly appreciated.
Thanks
Graham
XML
---
<resultset>
<result>
<activityid>{88320F75-4C77-4750-9E3F-C3991210941E}</activityid> <ownerid name="Admin, Sys" dsc="0" type="8">{31157DA0-9F83-4495-B91A-A3EB012F84A3}</ownerid> <owninguser>{31157DA0-9F83-4495-B91A-A3EB012F84A3}</owninguser> <objectid.contactid>{BC2119B2-3BD6-4B86-8D3C-26738ABD63B5}</objectid.contactid> <objectid.fullname>johnson, johnny</objectid.fullname> <objectid.accountid name="account 1 sub" dsc="0">{FD5180B0-D7D8-45A4-8665-34A2807D2F3D}</objectid.accountid> </result> <result> <activityid>{368CCF74-559C-450F-8DD4-23646DDB0787}</activityid> <ownerid name="Admin, Sys" dsc="0" type="8">{31157DA0-9F83-4495-B91A-A3EB012F84A3}</ownerid> <owninguser>{31157DA0-9F83-4495-B91A-A3EB012F84A3}</owninguser> <objectid.contactid>{BC2119B2-3BD6-4B86-8D3C-26738ABD63B5}</objectid.contactid> <objectid.fullname>johnson, johnny</objectid.fullname> <objectid.accountid name="account 1 sub" dsc="0">{FD5180B0-D7D8-45A4-8665-34A2807D2F3D}</objectid.accountid> </result> <result> <activityid>{368CCF74-559C-450F-8DD4-23646DDX0787}</activityid> <ownerid name="Admin, Sys" dsc="0" type="8">{31157DA0-9F83-4495-B91A-A3EB012F84A3}</ownerid> <owninguser>{31157DA0-9F83-4495-B91A-A3EB012F84A3}</owninguser> <objectid.contactid>{4FC6C984-6890-424E-9A73-30A5BA083422}</objectid.contactid> <objectid.fullname>bragg, billy</objectid.fullname> <objectid.accountid name="account2" dsc="0">{FG5180B0-D7D8-45A4-8665-34A2807D2F3D}</objectid.accountid> </result> </resultset>
XSLT
-----
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- Define keys used to group elements -->
<xsl:key name="keyContactGUID" match="result" use="objectid.contactid" />
<xsl:template match="/">
<html>
<body>
<h2>Grouping Test</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th>Contact</th>
<th># of Visits</th>
<th>Account</th>
</tr>
<xsl:variable name="countID" select="0"></xsl:variable>
<!-- Process each Contact-->
<xsl:for-each select="//result[generate-id(.) =
generate-id(key('keyContactGUID',objectid.contactid)[1])]"> <tr>
<xsl:variable name="CID"><xsl:value-of
select="objectid.contactid" /></xsl:variable>
<td><xsl:value-of
select="objectid.fullname"></xsl:value-of><p></p></td>
<td> <xsl:value-of
select="count(activityid[@CID=current])"></xsl:value-of></td> <td><xsl:value-of select="objectid.accountid/@name"></xsl:value-of></td> </tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
I am having trouble getting XSL to count the members of a group. What I am trying to do is group by <objectid.Contactid> and count the number of <activityid>'s for each <objectid.contactid>. My XSL keeps returning zero for the count. The results for the XML/XSLT files below should look like:-
Contact # of Visits Account
johnson, johnny 2 account 1 sub bragg, billy 1 account2
Any help would be greatly appreciated.
Thanks
Graham
XML
---
<resultset>
<result>
<activityid>{88320F75-4C77-4750-9E3F-C3991210941E}</activityid> <ownerid name="Admin, Sys" dsc="0" type="8">{31157DA0-9F83-4495-B91A-A3EB012F84A3}</ownerid> <owninguser>{31157DA0-9F83-4495-B91A-A3EB012F84A3}</owninguser> <objectid.contactid>{BC2119B2-3BD6-4B86-8D3C-26738ABD63B5}</objectid.contactid> <objectid.fullname>johnson, johnny</objectid.fullname> <objectid.accountid name="account 1 sub" dsc="0">{FD5180B0-D7D8-45A4-8665-34A2807D2F3D}</objectid.accountid> </result> <result> <activityid>{368CCF74-559C-450F-8DD4-23646DDB0787}</activityid> <ownerid name="Admin, Sys" dsc="0" type="8">{31157DA0-9F83-4495-B91A-A3EB012F84A3}</ownerid> <owninguser>{31157DA0-9F83-4495-B91A-A3EB012F84A3}</owninguser> <objectid.contactid>{BC2119B2-3BD6-4B86-8D3C-26738ABD63B5}</objectid.contactid> <objectid.fullname>johnson, johnny</objectid.fullname> <objectid.accountid name="account 1 sub" dsc="0">{FD5180B0-D7D8-45A4-8665-34A2807D2F3D}</objectid.accountid> </result> <result> <activityid>{368CCF74-559C-450F-8DD4-23646DDX0787}</activityid> <ownerid name="Admin, Sys" dsc="0" type="8">{31157DA0-9F83-4495-B91A-A3EB012F84A3}</ownerid> <owninguser>{31157DA0-9F83-4495-B91A-A3EB012F84A3}</owninguser> <objectid.contactid>{4FC6C984-6890-424E-9A73-30A5BA083422}</objectid.contactid> <objectid.fullname>bragg, billy</objectid.fullname> <objectid.accountid name="account2" dsc="0">{FG5180B0-D7D8-45A4-8665-34A2807D2F3D}</objectid.accountid> </result> </resultset>
XSLT
-----
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- Define keys used to group elements -->
<xsl:key name="keyContactGUID" match="result" use="objectid.contactid" />
<xsl:template match="/">
<html>
<body>
<h2>Grouping Test</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th>Contact</th>
<th># of Visits</th>
<th>Account</th>
</tr>
<xsl:variable name="countID" select="0"></xsl:variable>
<!-- Process each Contact-->
<xsl:for-each select="//result[generate-id(.) =
generate-id(key('keyContactGUID',objectid.contactid)[1])]"> <tr>
<xsl:variable name="CID"><xsl:value-of
select="objectid.contactid" /></xsl:variable>
<td><xsl:value-of
select="objectid.fullname"></xsl:value-of><p></p></td>
<td> <xsl:value-of
select="count(activityid[@CID=current])"></xsl:value-of></td> <td><xsl:value-of select="objectid.accountid/@name"></xsl:value-of></td> </tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>