I have this simple XML file:
557
Fleece Pullover&
BaseX is just being strict about serialization. It won't complain if you force the attribute nodes into strings:
xquery doc("catalog.xml")/*/product/@dept/string()
The XQuery 3.1 Serialization specification provides the new "adaptive" serialization mode, which allows the serialization of attribute and namespace nodes. Since Version 8.0 of BaseX, this mode is used as new default.