EDIT
Upon lettura il tuo post di nuovo, penso che la versione originale della mia risposta (sotto) non lo è.
È hai un elenco già - la vostra dichiarazione di variabile seleziona un nodo-set di tutti <country>
nodi che sono figli di <Request>
(un set di nodi è l'equivalente XSLT di un array/una lista):
<xsl:variable name="$country" select="Request/country" >
Ma il punto è che non hai nemmeno bisogno di elencare come variabile separata; tutto ciò che serve è:
<xsl:when test="Request[country=$country]"><!-- … --></xsl:when>
Dove Request[country=$country]
recita "Entro <Request>
, guardare ogni <country>
e selezionarlo se è uguale a $country
." Quando l'espressione restituisce un set di nodi non vuoto, $country
si trova nell'elenco.
Che è, infatti, quello che ha detto Rubens Farias dall'inizio. :)
Risposta originale, conservata per la cronaca.
Se per "lista" intendi una stringa separato da virgole di gettoni:
<!-- instead of a variable, this could be a param or dynamically calculated -->
<xsl:variable name="countries" select="'EG, KSA, UAE, AG'" />
<xsl:variable name="country" select="'KSA'" />
<xsl:choose>
<!-- concat the separator to start and end to ensure unambiguous matching -->
<xsl:when test="
contains(
concat(', ', normalize-space($countries), ', ')
concat(', ', $country, ', ')
)
">
<xsl:text>IN</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>OUT</xsl:text>
</xsl:otherwise>
</xsl:choose>
quella lista appartiene sul vostro input XML? –
Qual è l'input XML come? I codici Paese sono nodi di testo o elementi o ad es. attributi? –
jelovirt