Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old March 26th, 2007, 08:40 AM
Authorized User
Join Date: Mar 2007
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default XSLT count()

here is my XML

<?xml version="1.0" encoding="utf-8" ?>
   <bookingDetails id="1">
   <invoice>HBK / 20Jan2007 / 12</invoice>
   <cost>100 AED</cost>

and here is XSLT

<xsl:template match="/">
  <title>How to select between two dates</title>
    <xsl:apply-templates />
<xsl:template match="bookingMain">
  <table width="800" border="1" bordercolor="#0000cc" ID="Table2" cellpadding="0" cellspacing="0">
   <td colspan="9" height="6" bgcolor="#000099"></td>
 <tr bgcolor="#ccccff" class="tdfont">

   <td>Service #</td>
   <td>Client Name</td>
   <td>Booking Ref.</td>
  <xsl:apply-templates select="//bookingDetails[concat(substring-after(substring-after(bookDate,'-'),'-'),substring(substring-after(bookDate,'-'),1,2),substring-before(bookDate,'-')) &gt;= concat(substring-after(substring-after($chkIDate,'-'),'-'),substring(substring-after($chkIDate,'-'),1,2),substring-before($chkIDate,'-')) and concat(substring-after(substring-after(bookDate,'-'),'-'),substring(substring-after(bookDate,'-'),1,2),substring-before(bookDate,'-')) &lt;= concat(substring-after(substring-after($chkODate,'-'),'-'),substring(substring-after($chkODate,'-'),1,2),substring-before($chkODate,'-'))]" />

</table><p />

<xsl:template match="bookingDetails">


   <td><xsl:value-of select="@id" /></td>
   <td><xsl:value-of select="service" /></td>
   <td><xsl:value-of select="clientName" /></td>
   <td><xsl:value-of select="bookingRef" /></td>
   <td><xsl:value-of select="invoice" /></td>
   <td><xsl:value-of select="cost" /></td>
   <td><xsl:value-of select="pax" /></td>
   <td><xsl:value-of select="amount" /></td>
   <td><xsl:value-of select="balance" /></td>

[u]basically i am selection the values between two dates, now i want to calculate the total number f IDs by the above applied template. when i use the <xsl:value-of select="count(@id)" /> it only gives the current id, means does not return the exact value..can someone suggest where i should put the count() fucntion. </u>

I Love XML and family
I Love XML and family
Old March 26th, 2007, 08:51 AM
mhkay's Avatar
Wrox Author
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts


<xsl:apply-templates select="EXPR"/>


<xsl:variable name="nodes" select="EXPR"/>
<xsl:apply-templates select="$nodes"/>
<xsl:value-of select="count($nodes)"/>

Michael Kay
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Old March 26th, 2007, 08:55 AM
Authorized User
Join Date: Mar 2007
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts

thanks alot, it works fine now. thanks dear

I Love XML and family

Similar Threads
Thread Thread Starter Forum Replies Last Post
XSL: Count = Count + 1 elayaraja.s XSLT 3 July 18th, 2008 03:21 AM
Can XSLT read DTD/schema and Generate XSLT.. ROCXY XSLT 1 November 6th, 2006 09:39 AM
dynamic xslt -> xslt creation namespace problem jkmyoung XSLT 2 July 15th, 2006 12:42 AM
is there any in built function to count page count g.tamilselvan MySQL 1 February 15th, 2006 07:43 AM
Count, sum, count a value, return records CongoGrey Access 1 April 18th, 2005 02:25 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.