dazzle
dazzle

Reputation: 1346

OR condition not working in xlst if

<xsl:when test="person/id!=127 or 112" >

or condition is not working in the above example. Please help

Upvotes: 3

Views: 650

Answers (4)

nkaya
nkaya

Reputation: 21

I am not an xslt developer and never used it before. However, It appears that test statement is missing. what should xslt parser do with 112? no condition is provided for it.

Upvotes: 0

Dimitre Novatchev
Dimitre Novatchev

Reputation: 243569

Use:

 not(person/id= 127 or person/id = 112)

Try to always avoid the != XPath operator, due to its unintuitive (and rarely useful) semantics when one or both of its arguments are node-sets 9or sequences in XPath 2.0).

When you have a long list to compare against, this kind of expression may be more convenient and efficient:

not(contains('|101|105|108|112|123|127|', concat('|', person/id, '|'))

Upvotes: 0

bryanjonker
bryanjonker

Reputation: 3416

Try <xsl:when test="person/id!=127 and person/id!=112">

Upvotes: 1

Sergey Kalinichenko
Sergey Kalinichenko

Reputation: 726987

You've got your syntax wrong, and it should be an and, not or. Try this:

<xsl:when test="person/id!=127 and person/id!=112" >

If you put an or there, your condition is going to be true no matter what the value of ID is, because no number can equal 127 and 112 at the same time.

Upvotes: 2

Related Questions