An UpdateIfExpr
is a conditional expression for use in
an update expression. If the expression following the if
keyword
evaluates to true, the update expression following the then
keyword is applied, otherwise the update expression following the
else
keyword is applied.
If the then
branch and/or the else
branch does
not require any update operations, an empty pair of parentheses should be
used.
Note that the else
clause is mandatory.
Insert an attribute, if it does not exist yet, otherwise replace the
existing attribute, if its value is less then 100. This query contains two
UpdateIfExpr
constructs, where the second one occurs in the
else
branch of the first:
update for $book in input()/bib/book do if (empty($book/@year)) then insert attribute year {year-from-date(current-date())} into $book else if ($book/@year < 100) then replace $book/@year with attribute year {1900 + $book/@year} else ()
The following construct(s) refer to this construct: