viv:switch-string
switch function that is based on string arguments
Synopsis
object viv:switch-string (str, str-test-1, obj-1, ..., str-test-n, obj-n, obj-other); string str; string str-test-1; object obj-1; ... ; string str-test-n; object obj-n; object obj-other;
Description
Simple switch statement (which does not exist in XPath 1.0) based on the value of string.
Arguments
- str: the string whose value is tested.
- str-test-1, str-test-n: test strings which will be compared to str
- obj-1, obj-n: objects (string, node-set, etc) to return when their respective string matches the test string.
- object-other: the object (string, node-set, etc) to if a respective string match is false. The default value for this parameter is the empty string, '""'.
Returns
- obj-i if str-test-i is equal to str
- object-other if none of the conditions is verified.
Example
<xsl:value-of select="viv:switch-string(@source, 'MSN', 1, 'Yahoo', 2, 3)"/>