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 December 4th, 2006, 06:12 AM
Authorized User
 
Join Date: Sep 2006
Posts: 92
Thanks: 0
Thanked 0 Times in 0 Posts
Default Count() and filtering

Count & Filtering

I hope that someone can help me with this little issue:

With some reports I get very slow response from a generate-id clause ...

<xsl:for-each select="rep_base[generate-id()=generate-id(key('kteam', tm)[plant=$pfiltfld) and (FS_CNT != '')])]">

... so am switching to count() syntax which (in my case) is much faster. Here is an expample:

<xsl:for-each select="rep_base[count(.| key('kteam', tm)[1])=1 and (plant=$pfiltfld)]">

... which works fine (NB: Here all entries are allocated to one or other 'plant').

However, I would now like to add the second filter FS_CNT != '' (as in the first, generate-id, clause) to test for the entry of an FS_CNT item/attribute. Here I came up with the following syntax:

<xsl:for-each select="rep_base[count(.| key('kteam', tm)[FS_CNT != ''])=1 and (plant=$pfiltfld)]">

... but find that it doesn't seem to test all nodes. Let me explain:

I have some teams which, in some entries have FS_CNT data but in others do not. So, when I apply my FS_CNT != '' filter if the first entry for a team happens to be empty then the team will not be displayed even though other entries have data.

I am sure that this is a logic/understanding problem in my syntax and hope that someone can help me to correct this. Indeed, I have tried other variations such as:

<xsl:for-each select="rep_base[count(.| key('kteam', tm)[1])=1 and (plant=$pfiltfld) and (FS_CNT != '')]">

... but this gave me the same problem.

I could return to using 'generate-id' syntax but, although the correct data is returned, generate-id is extremely slow.

Here I really believe that, if I can get my mind around how the count() function accepts the filter clause, then I can get it to work.

Many thanks for any tips that you can give me.

Regards,
Alan.

 
Old December 4th, 2006, 06:19 AM
Authorized User
 
Join Date: Sep 2006
Posts: 92
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I was wondering ...

Could I do something like:

<xsl:for-each select="rep_base[count(.| key('kteam', tm)[max(FS_CNT)])=1 and (plant=$pfiltfld) and (FS_CNT != '')]">

... so that the count() clause always selects the top value (max) FS_CNT value and thereby is able to apply the FS_CNT != '' correctly.

This is stabbing in the dark and I did try this syntax but (of course) it didn't work.

Regards and thanks,
Alan Searle






Similar Threads
Thread Thread Starter Forum Replies Last Post
How to use OR during filtering..... raaj81 Reporting Services 0 July 30th, 2008 05:34 AM
XSL: Count = Count + 1 elayaraja.s XSLT 3 July 18th, 2008 03:21 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
Chapter 4 - Filtering example pehrig BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 6 September 24th, 2004 02:39 PM





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