I have the following:
<xsl:when test="(PropertyType[@PropertyType=1])
and ($year - YearBuild < 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.
精彩评论