如何检查值是否在值序列中?

sno*_*kin 8 xml xslt xpath

我有以下内容:

<xsl:when test="(PropertyType[@PropertyType=1]) 
                and ($year - YearBuild  &lt; 3)"
 >New</xsl:when>
Run Code Online (Sandbox Code Playgroud)

我想测试几个属性类型的属性标记,并且不仅为1,例如,在上面的例子中我检查,如果属性属性类型的元素的属性类型是等于1,我要检查它是否:等于1或2的,或10或11或....(一个数字列表)如何?

谢谢

小智 9

您想测试某个标量值是否属于序列.

在XPath 1.0中(没有序列数据类型):

PropertyType[contains(' 1 2 10 11 ',concat(' ',@PropertyType,' ')]  
Run Code Online (Sandbox Code Playgroud)

在XPath 2.0中(带序列数据类型):

PropertyType[@PropertyType = (1,2,10,11)]
Run Code Online (Sandbox Code Playgroud)

注意:存在比较.