Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 15th, 2008, 01:35 AM
Registered User
Join Date: Dec 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default count in XSLT, Need Help Please !!!

I am creating a report using a xml (Input File(Source).
In the xml I have Parents Source , Then I have ID, S_ID, Name , Discription, DATE, TIME and STATUS , For Each ID I will be having 96 DATE and TIME, some time I may have 80 or 70 also , But max count will be 96.
I am getting all the column correct in the report, now I am trying to get a new column TOTAL COUNT ( which count all the Date / Time / Status, STATUS value will be "1" by default. If I sum the STATUS.
Below is the XSLT iam trying to right , but If I use count it is displaying 2796 in each, I didn't put the whole xml here I just added 4 - 5 count here as an example.
why I am getting 2796 ( becuase I pulled 1 month i data means 31 days each day will have 96 S_ID , DATE, TIME, STATUS) so the XSLT is count 96 * 31 and displaying 2796 in each row.
The ID is also unique for 96 Measure
<?xml version="1.0" encoding="UTF-8"?>
<xml_transfer xmlns="" version="V1.2">
.***********<96 MEASURE> element*********
( 96 <MEASURE>)
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="text()|@*"/>
<xsl:key name="fact" match="MEASURE" use="concat(S_ID, ' ', DATE)"/>
<xsl:template match="//rep:envelope/rep:sources/rep:source/rep:data/xml_transfer/REPORT">
<!-- Headers -->
<table><tr><td align="left" colspan="7"><font size="5"><b><i><u>My Report</u></i></b></font></td></tr> <!-- Report title -->

<table border="1"> <!-- Headers -->
<th colspan="7">Parent Facility</th>
<th>TOTAL COUNT</th>
<xsl:for-each select="ESOURCE">
<table border="1"><tr>
<td><xsl:value-of select="descendant::ESOURCE_TEXT[last()]/NAME"/></td>
<td><xsl:value-of select="descendant::ESOURCE_TEXT[last() - 1]/NAME"/></td>
<td><xsl:value-of select="descendant::ESOURCE_TEXT[last() - 2]/NAME"/></td>
<td><xsl:value-of select="descendant::ESOURCE_TEXT[last() - 3]/NAME"/></td>
<td><xsl:value-of select="descendant::ESOURCE_TEXT[last() - 4]/NAME"/></td>
<td><xsl:value-of select="descendant::ESOURCE_TEXT[last() - 5]/NAME"/></td>
<td><xsl:value-of select="descendant::ESOURCE_TEXT[last() - 6]/NAME"/></td>
<td><xsl:value-of select="ESOURCE_TEXT/NAME"/></td>
<td><xsl:value-of select="ESOURCE_TEXT/DESCRIPTION"/></td>
<td><table><xsl:for-each select="MEASURE[count(. | key('fact', concat(S_ID, ' ', MAT_ID, ' ', DATE))[1]) = 1]">
<xsl:sort select="MATERIAL_TEXT/NAME"/>
<xsl:sort select="DATE"/>
<td><xsl:value-of select="MATERIAL_TEXT/NAME"/></td>
<td><xsl:value-of select="START_DATE"/></td>
<td><xsl:value-of select="count(//STATUS[.=current()/STATUS])"/></td>
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
XSL: Count = Count + 1 elayaraja.s XSLT 3 July 18th, 2008 03:21 AM
XSLT count() sani723 XSLT 2 March 26th, 2007 08:55 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

All times are GMT -4. The time now is 06:07 AM.

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