RE: [xsl] Comparing Node Text Content with a String Set

Subject: RE: [xsl] Comparing Node Text Content with a String Set
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Tue, 28 Oct 2003 08:16:50 -0000
> ie.. instead of having the following <if test> syntax
> all through my multiple xslt files:
> 
> <xsl:if test="ACCTTYPE = 'AAA' or
>               ACCTTYPE = 'BBB' or
>               ACCTTYPE = 'CCC' or
>               ACCTTYPE = 'DDD' or
>               ACCTTYPE = 'EEE'">
> 	        
> I am curious if there is a way to define this once in
> a common xslt file which is then imported into my many
> xslt files, so if new types are added or removed, it
> only has to be changed once?

It's easy if you use the xx:node-set() extension.

Declare a global variable:

<xsl:variable name="lookup">
  <key>AAA</key>
  <key>BBB</key>
  <key>CCC</key>
</xsl:variable>

then <xsl:if test="ACCTTYPE = xx:node-set($lookup)/key".

If you don't want to use the extension function you can access the
lookup table by putting it in a separate XML document.

Michael Kay


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread