Annotations (xs:documentation/xs:appinfo) for instance documents in analogy to XML schema annotations

You could use processing-instructions. A processing instruction has two components, a target and optional content:

https://en.wikipedia.org/wiki/Processing_Instruction

An XML processing instruction is enclosed within <? and ?>, and contains a target and optionally some content, which is the node value, that cannot contain the sequence ?>.

<?PITarget PIContent?>

The advantage of PIs are that it is outside of the content markup and XSD validation, and most default rendering ignores it.

It provides a convenient way to use the PI target as a "key" for lookup and categorization and then the content can have whatever you decide.

So, if you had a processing instruction in your XML:

<?expectedError MissingRequiredElementException?>

you could access it with by the target name "expectedError":

//processing-instruction("expectedError")