tags:

views:

43

answers:

1

I want to check if a value exists in a sequence defined as

<xsl:variable name="some_seq" select="/root/word[@optional='no']/text()"/>

In the past, I've had success with Priscilla Walmsleys function. For clarity, I reproduce it here as follows:

<xsl:function name="functx:is-value-in-sequence" as="xs:boolean">
    <xsl:param name="value" as="xs:anyAtomicType?"/>
    <xsl:param name="seq" as="xs:anyAtomicType*"/>
    <xsl:sequence select="$value=$seq"/>
</xsl:function>

However, this time I need to make a case-insensitive comparison, and so I tried to wrap both $value and $seq with a lower-case(). Obviously, that didn't help much, as $seq is a sequence and lower-case() takes only strings.

Question: what is the best way to either 1) construct a sequence of lower-case strings, or 2) make a case-insensitive comparison analogous to $value=$seq above? TIA!

A: 

Use a "for-expression" inside the function to prepare a lower-case version of the sequence

<xsl:variable name="lcseq" select="for $i in $seq return lower-case($i)"/>

See Michael Kay's "XSLT 2.0 and XPATH 2.0, 4th ed", p. 640

(I haven't tested this)

Jim Garrison