This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: for-each with included variable


>
> <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']]"
         use="1"/>

<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:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]