More Help Counting

G

Graham

Hi,
I am in need of help trying to count the number of records that a Key
group contains. I am a newbie and apologise if this seems a dumb
request!

I have the following XSLT and keep getting zero returned.

<?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="/">
<!-- autonumber for the sorting id column -->
<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="CC"
select="count(key('keyContactGUID',objectid.contactid))"/>
<!-- 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"/>
<p/>
</td>
<td>
<xsl:value-of
select="count(key('keyContactGUID',objectid.contactid)/activityid)"/>
</td>
<td>
<xsl:value-of select="objectid.accountid/@name"/>
</td>
</tr>

</xsl:for-each>


</table>
<xsl:variable name="CC"
select="count(key('keyContactGUID',objectid.contactid))"/>
Count = <xsl:value-of select="$CC"/>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

Thanks in advance
Graham.
 
O

Oleg Tkachenko [MVP]

Graham said:
I am in need of help trying to count the number of records that a Key
group contains. I am a newbie and apologise if this seems a dumb
request!

I have the following XSLT and keep getting zero returned.

Well, you forgot to provide a sample input XML.
 
O

Oleg Tkachenko [MVP]

Graham wrote:

<xsl:template match="/">
<!-- autonumber for the sorting id column -->
<html>
<body>

As you can see here context node is root. There is no objectid.contactid
element in this context.
<xsl:variable name="CC"
select="count(key('keyContactGUID',objectid.contactid))"/>
Count = <xsl:value-of select="$CC"/>

I'm not sure which count you need, but try somethng like
<xsl:variable name="CC"
select="count(key('keyContactGUID',//result/objectid.contactid))"/>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,240
Members
46,830
Latest member
HeleneMull

Latest Threads

Top