Search code examples
xmlxpathxsltxslt-2.0xpath-2.0

Xpath Is there a less verbose way to filter with multiple 'contain' conditions?


and (contains(BusinessType,'Restaurant') or contains(BusinessType,'Pub') or contains(BusinessType,'Takeaway') <snip...>)

The above works as expected returning cases containing the specified words, but is there a less verbose/more efficient code?

Something like this, but actually works?

and (contains(BusinessType,'Restaurant|Pub|Takeaway'))

Solution

  • matches() takes a regex and will do what you want:

    matches(BusinessType,'Restaurant|Pub|Takeaway')