Otherwise operator

Saxon provides an additional operator: otherwise. The expression A otherwise B returns the value of A unless it is an empty sequence, in which case it returns the value of B. For example, the expression:

chapter[title='Introduction'] otherwise chapter[1]

returns the chapter(s) entited "Introduction" if such a chapter exists; otherwise it returns the first chapter.

The precedence of the operator is greater than arithmetic operators (so $n div $m otherwise 1 means $n div ($m otherwise 1)), but less than the "union" operator (so a/b/c otherwise 0 means (a/b/c) otherwise 0).