I have a concatenation of AND and OR for 2 different variables. And I tried the following:
<xsl:if test="$countryCode = '104'
and
(transactionType != 'Allowance'
or
revenueCenter != '1100')">
But that does not work. Is it possible to do a conditional test or do I have to split it up like this:
<xsl:if test="$countryCode='104'>
and in a second element I do:
<xsl:if transactionType!='Allowance' or revenueCenter!='1100'>
The XPath expression:
$countryCode='104'
and
(transactionType!='Allowance' or revenueCenter!='1100')
is syntactically correct.
We cannot say anything about the semantics, as no XML document is provided and there is no explanation what the expression must select.
As usual, there is the recommendation not to ose the !=
operator, unless really necessary -- its use when one of the arguments is a node-set (or sequence or node-set in XPath 2.0) is very far from what most people expect.
Instead of !=
better use the function not()
:
$countryCode='104'
and
(not(transactionType='Allowance') or not(revenueCenter='1100'))
and this can further be refactored to the shorter and equivalent:
$countryCode='104'
and
not(transactionType='Allowance' and revenueCenter='1100')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With