Re: [xsl] Using a keys to filter based on [not(someelement)]

Subject: Re: [xsl] Using a keys to filter based on [not(someelement)]
From: andrew welch <andrew.j.welch@xxxxxxxxx>
Date: Sun, 7 Aug 2005 22:21:33 +0100
> Grouping seems pretty easy when defining keys that are inclusive such as:
> <xsl:key name="recordByC" match="Record" use="CodeId"/>
> <xsl:variable name="uh2" select="key('recordByC','30DAYPM')"/>
> but what about using a key to exclude a Record based on a certain
> element.  That is, I want to ignore all Records when a <Fodder/>
> element is present.
> Is using the predicate after the key is resolved the only method:
> <xsl:variable name="uh2" select="key('recordByC','30DAYPM')[not(Fodder)]"/>
> is there anyway that I can define this within the use attribute of the key?

Wouldn't it go in the match? eg:

<xsl:key name="recordByC" match="Record[not(Fodder)]" use="CodeId"/>

Only Record elements without Fodder children would then exist in the key.


Current Thread