开发者

How to check if a value is in a sequence of values?

I have the following:

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

I want to test for several PropertyType attribute numbers, and not only for 1, for instance, in the above example I check if the attribute PropertyType of the element P开发者_开发百科ropertyType is equals to 1, I want to check if it: equals to 1 or 2, or 10 or 11 or .... (a list of numbers) how to?

Thanks


You want to test if some scalar value belongs to a sequence.

In XPath 1.0 (without sequence data type):

PropertyType[contains(' 1 2 10 11 ',concat(' ',@PropertyType,' ')]  

In XPath 2.0 (with sequence data type):

PropertyType[@PropertyType = (1,2,10,11)]

Note: Existencial comparison.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜