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