This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Is it possible to filter for all "distinct" nodes having a"specific" date?
- From: "Joerg Heinicke" <joerg dot heinicke at gmx dot de>
- To: <xsl-list at lists dot mulberrytech dot com>
- Date: Sat, 16 Mar 2002 00:36:53 +0100
- Subject: Re: [xsl] Is it possible to filter for all "distinct" nodes having a"specific" date?
- References: <2a32b37589309113be55c3517b987ee93c925f86@>
- Reply-to: xsl-list at lists dot mulberrytech dot com
Hi Gregory,
if you add the node-number to the stylesheet:
Node: <xsl:value-of select="count(preceding-sibling::*) + 1"/>
you can see this output:
specific date:
PageName: A Date: 31502 Node: 7
PageName: A Date: 31502 Node: 8
PageName: B Date: 31502 Node: 9
PageName: B Date: 31502 Node: 10
PageName: C Date: 31502 Node: 11
PageName: C Date: 31502 Node: 12
distinct pagename:
PageName: A Date: 21502 Node: 1
PageName: B Date: 21502 Node: 3
PageName: C Date: 21502 Node: 5
Now find a node, which is in both groups. You won't find one and the
stylesheet finds no node too. This is because before the '31502'-nodes there
is always another node with '21502', so the test on pagename is always
wrong. You have to add the date-test to the pagename-test too:
<xsl:apply-templates
select="records/record[translate(date,'/','')='31502'][not(preceding-sibling
::record[translate(date,'/','')='31502']/pagename = pagename)]"/>
Output:
PageName: A Date: 31502 Node: 7
PageName: B Date: 31502 Node: 9
PageName: C Date: 31502 Node: 11
Regards,
Joerg
----- Original Message -----
From: "Gregory Pearson" <GregP@nbsys.com>
> Hi. I am trying to get all the "distinct" records (by "pagename") for a
specific date. If I filter for just the "distinct" records it works. If I
filter for just the "specific" date it works. If I do both at the same time
it doesn't work. Does anyone have any idea what I need to do differently?
Thanks
>
> Please see the xml & xsl files below ...
>
> [xsl file]
>
> <?xml version="1.0"?>
> <xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
>
> <xsl:template match="/">
>
> <html>
> <body>
>
> <!-- GET ALL [RECORD] ELEMENTS WITH SPECIFIC DATE & DISTINCT 'pagename':
DOES NOT WORK IF BOTH ARE SPECIFIED -->
> <!-- <xsl:apply-templates
select="records/record[translate(date,'/','')='31502' and
not(preceding-sibling::record/pagename = pagename)]"/> -->
>
> <!-- GET ALL [RECORD] ELEMENTS WITH SPECIFIC DATE: WORKS! -->
> <xsl:apply-templates
select="records/record[translate(date,'/','')='31502']"/>
>
> <!-- GET ALL [RECORD] ELEMENTS WITH DISTINCT 'pagename': WORKS! -->
> <!-- <xsl:apply-templates
select="records/record[not(preceding-sibling::record/pagename =
pagename)]"/> -->
>
> </body>
> </html>
>
> </xsl:template>
>
> <xsl:template match="record">
>
> PageName: <xsl:value-of select="pagename"/>
> Date: <xsl:value-of select="date"/>
> <br></br>
>
> </xsl:template>
>
> </xsl:stylesheet>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list