SAP CPI complex filtering with string containing tokens using XSLT

Complex Filter, using an input string with a list of tokens. We have to get all the corresponding objects with one of the field value corresponding to one of those tokens.

In this exemple, we want to select all the records “Object” with a Category with a value “TOKENA”, “TOKENB” or “TOKENC”

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
	exclude-result-prefixes="#all">
 <xsl:param name="TokenList"   select="'TOKENA,TOKENB,TOKENG'" as="xs:string"/>
 <xsl:output omit-xml-declaration="yes" indent="yes"/>
 <xsl:variable name='Apos'>|</xsl:variable>
 <xsl:variable name='Allowed'><xsl:for-each select="tokenize($TokenList, ',\s*')">
   <xsl:value-of select="concat($Apos, normalize-space(.), $Apos)"/>
 </xsl:for-each></xsl:variable>

 <xsl:template match="/">
  <Result>
    <ResultSet>
      <xsl:for-each select="/Collection/Object">
      <xsl:if test="contains($Allowed, SubRecord/Category )">
          <Record>
          <!-- Map fields here-->
            <Field1><xsl:value-of select="Source1"/></Field1>
            ...
          </Record>
      </xsl:if>  
      </xsl:for-each>
    </ResultSet>
  </Result>
</xsl:template>

</xsl:stylesheet>