I am wondering why xs:string("&") is not possible, but xs:string("<") is (although XML does not allow both ). Is there any reason? Thanks.
You are allowed to use some predefined entity references and to
use character references in string literals, see https://www.w3.org/TR/xquery-31/#prod-xquery31-StringLiteral
which defines
[222] StringLiteral ::= ('"' (PredefinedEntityRef | CharRef | EscapeQuot | [^"&])* '"') | ("'" (PredefinedEntityRef | CharRef | EscapeApos | [^'&])* "'")
so you can use the ampersand as a meta character for e.g. `<` and e.g. ` `, on the other hand, to use it literally, you need some escape mechanism in the form of `&`.
Inside XML the angle brackets are needed for markup but that is
not the case inside of a string literal so you can use them freely
in there.