Does contains()
work for multiple words stored in a variable? Will the below one work? If it won\'t work, please help me with a solution.
Assuming that you're looking to do a logical OR of substring containment...
First of all, this select
is likely wrong1:
It's looking for an element named footballvolleyballchesscarrom
. If you're trying to set games to the string footballvolleyballchesscarrom
, change it to this:
Then, use either
CORRECT
or
CORRECT
to test whether $games
contains one of your multiple substrings.
1 If you really intended to select (possibly multiple) elements from the input XML here, there is another XSLT 2.0 option for testing the selected sequence against a set of possible values. If your input XML were, say,
football
volleyball
chess
carrom
then this template,
CORRECT
would output CORRECT
because among the string values of the selected elements is at least one of chess
or carrom
.