Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>EDIT</p> <p>Upon reading your post again, I think the original version of my answer (below) is not it.</p> <p>You <em>have</em> a list already - your variable declaration selects a node-set of all <code>&lt;country&gt;</code> nodes that are children of <code>&lt;Request&gt;</code> (a node-set is the XSLT equivalent of an array/a list):</p> <pre><code>&lt;xsl:variable name="$country" select="Request/country" &gt; </code></pre> <p>But the point is, you don't even <em>need</em> that list as a separate variable; all you need is:</p> <pre><code>&lt;xsl:when test="Request[country=$country]"&gt;&lt;!-- … --&gt;&lt;/xsl:when&gt; </code></pre> <p>Where <code>Request[country=$country]</code> reads as "Within <code>&lt;Request&gt;</code>, look at every <code>&lt;country&gt;</code> and select it if it is equal to <code>$country</code>." When the expression returns a non-empty node-set, <code>$country</code> is in the list.</p> <p>Which is, in fact, what Rubens Farias said from the start. :)</p> <hr> <p>Original answer, kept for the record.</p> <p>If by "list" you mean a comma-separated string of tokens:</p> <pre><code>&lt;!-- instead of a variable, this could be a param or dynamically calculated --&gt; &lt;xsl:variable name="countries" select="'EG, KSA, UAE, AG'" /&gt; &lt;xsl:variable name="country" select="'KSA'" /&gt; &lt;xsl:choose&gt; &lt;!-- concat the separator to start and end to ensure unambiguous matching --&gt; &lt;xsl:when test=" contains( concat(', ', normalize-space($countries), ', ') concat(', ', $country, ', ') ) "&gt; &lt;xsl:text&gt;IN&lt;/xsl:text&gt; &lt;/xsl:when&gt; &lt;xsl:otherwise&gt; &lt;xsl:text&gt;OUT&lt;/xsl:text&gt; &lt;/xsl:otherwise&gt; &lt;/xsl:choose&gt; </code></pre> <hr>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload