Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > More Help Counting

Reply
Thread Tools

More Help Counting

 
 
Graham
Guest
Posts: n/a
 
      09-20-2004
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"
xmlnssl="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.contac tid))"/>
<!-- 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.contac tid)/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.contac tid))"/>
Count = <xsl:value-of select="$CC"/>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

Thanks in advance
Graham.
 
Reply With Quote
 
 
 
 
Oleg Tkachenko [MVP]
Guest
Posts: n/a
 
      09-20-2004
Graham wrote:

> 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.

--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com
 
Reply With Quote
 
 
 
 
Oleg Tkachenko [MVP]
Guest
Posts: n/a
 
      09-20-2004
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.contac tid))"/>
> 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))"/>

--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com
 
Reply With Quote
 
 
 
Reply

Thread Tools

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Kamaelia 0.4.0 RELEASED - Faster! More Tools! More Examples! More Docs! ;-) Michael Python 4 06-26-2006 08:00 AM
Need help for counting records in asp.net joshimahen@gmail.com ASP .Net 2 04-19-2006 10:35 PM
With a Ruby Yell: more, more more! Robert Klemme Ruby 5 09-29-2005 06:37 AM
counting up instead of counting down edwardfredriks Javascript 6 09-07-2005 03:30 PM
Help with counting lines? Davidd Sargent Perl 3 08-13-2004 02:30 PM



Advertisments