Conditional Expressions
XPath 2.0 introduced a conditional expression of the form if ( E1 ) then E2 else
E3
. For example, if (@discount) then @discount else 0
returns the
value of the discount
attribute if it is present, or zero otherwise.
It's also worth noting the coding pattern (@price, 5)[1]
which returns the
value of @price
if it exists, or 5 otherwise.