Search code examples
xslt-2.0

XSLT 2.0: Check if string ends with a value from an array


How can I detect that a string ends with a value from a pre-determined array? Couldn't figure it out myself from other questions on SO because they ask about a complete string match.

Something like this

<xsl:template match="card">
    <xsl:variable name="word" select="k" />
    <xsl:variable name="obviouslyRussianSuffixes" select="('изм', 'ия', 'ист', 'ёр', 'ца', 'фон')" />
    <xsl:if test="ends-with($word, $obviouslyRussianSuffixes)">
        <xsl:value-of select="$word" />
        <xsl:text>&#xa;</xsl:text>
    </xsl:if>
</xsl:template>

Solution

  • I think you want the test to be some $suffix in $obviouslyRussianSuffixes satisfies ends-with($word, $suffix).