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 check several propertyType attribute numbers, and not only for 1, for example, in the above example, I check if the PropertyType attribute of the PropertyType element is 1, I want to check whether it is: 1 or 2, or 10 or 11 or. ... (list of numbers) how?

thanks

+7
source share
1 answer

You want to check if any scalar value of the sequence belongs.

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 Experimental comparison.

+8
source

All Articles