BaseX attributes cannot be serialized
basex, xml, xpath, xquery
Solution
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()
Problem
I have this simple XML file: ``` <catalog> <product dept="WMN"> <number>557</number> <name language="en">Fleece Pullover</name> <colorChoices>navy black</colorChoices> </product> <product dept="ACC"> <number>563</number> <name language="en">Floppy Sun Hat</name> </product> <product dept="ACC"> <number>443</number> <name language="en">Deluxe Travel Bag</name> </product> <product dept="MEN"> <number>784</number> <name language="en">Cotton Dress Shirt</name> <colorChoices>white gray</colorChoices> <desc>Our<i>favorite</i>shirt!</desc> </product> </catalog> ``` I am reading a book called XQuery by Priscila Walmsley and it says to type the command: ``` doc("catalog.xml")/*/product/@dept ``` so I type in BaseX ``` xquery doc("catalog.xml")/*/product/@dept ``` and I am getting this error: ``` Error: [SENR0001] Attributes cannot be serialized:attribute dept { "WMN" }. ``` Despite that the book that says: will return the four dept attributes in the input document. What am I doing wrong?