pethel
pethel

Reputation: 5537

Contains value xslt2

How is it possible to check if an array of for example Strings contains a String?

<xsl:if test="inArray('a', $array)"></xsl:if>

Upvotes: 2

Views: 1262

Answers (1)

Daniel Haley
Daniel Haley

Reputation: 52848

If by array you mean sequence, just use =...

    <xsl:variable name="array" select="('a','b','c')"/>
    <xsl:if test="$array='a'"></xsl:if>

You can also test multiple values in an array/sequence (this example will evaluate true if a or c exists in the sequence):

    <xsl:if test="$array=('a','c')"></xsl:if>

Upvotes: 8

Related Questions