RE: [xsl] for-each with included variable

Subject: RE: [xsl] for-each with included variable
From: "Michael Kay" <mhkay@xxxxxxxxxxxx>
Date: Thu, 19 Apr 2001 11:14:03 +0100
> <xsl:for-each select="(.//*[@OPTypeRef='Type1'])[1] |
> (.//*[@OPTypeRef='Type2'])[1] | (.//*[@OPTypeRef='Type3'])[1]">
>   <!-- do some stuff -->
> </xsl:for-each>
Someone else has pointed out your simple coding error, but how about a
completely different approach:

<xsl:key name="OKtypes"
         match="*[@OPTypeRef[.='Type1' or .='Type2' or .='Type3']]"

<xsl:for-each select="key('OKtypes', 1)[1]"> ...

(This only works if ".//*" in your code is searching the whole document: if
not, you could change the use= in the key to be the generate-id() of the
relevant ancestor node.)

Mike Kay
Software AG

 XSL-List info and archive:

Current Thread