最近,我使用XSLT 编写了一些个人程序。我很惊讶 XPATH 有“if then else”语句,没有“else if”。
例如,我只能使用:
if *** then ***
else ***
Run Code Online (Sandbox Code Playgroud)
但我不能使用:
if *** then ***
else if *** then ***
else ***
Run Code Online (Sandbox Code Playgroud)
XPath 是否支持 else-if 语句?模拟 else-if 的唯一方法是嵌套 if else?
一个表达式,例如
if (x=3)
then 1
else if (x=4)
then 5
else 6
Run Code Online (Sandbox Code Playgroud)
在 XPath 2.0 中是完全合法的。