XML well-formedness check: Attribute cannot appear outside of element declaration. Rewrite your XQuery so it returns well-formed ...