can’t find the answer anywhere whether you can do test="$var in ('Val1','Val2','Val3')" in XSLT instead of doing test="$var='Val1' or $var='Val2' or $var='Val3'"?
can’t find the answer anywhere whether you can do test=$var in (‘Val1′,’Val2′,’Val3’) in XSLT
Share
In XSLT 1.0, you can use the
contains()function:It returns a boolean result, testing whether the first string contains the second string.
A common way to help reduce false-positive results for partial string matches is to use a delimiter and pad the values with that delimiter:
That way, if the value of
$varwas “Val“, it would only return true if “Val” were added to the list of values being tested.In XSLT 2.0, you could use:
It will return true if
$varis equal to any of the items in the sequence (which is what you define when you have a comma separated list of values inside of parenthesis).Another XSLT 2.0 solution: