开发者

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

开发者 https://www.devze.com 2023-02-07 10:35 出处:网络
I have the following: <xsl:when test=\"(PropertyType[@PropertyType=1]) and ($year - YearBuild&lt; 3)\"

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

精彩评论

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