Error when get attributes with xquery in basex 7.9

145 Views Asked by At

This is the XML input:

<bookstore>
  <book category="COOKING">
  <title lang="en">Everyday Italian</title>  
  <author>Giada De Laurentiis</author>
    <year>2005</year>
   <price>30.00</price>
  </book>
  <book category="CHILDREN">
    <title lang="en">Harry Potter</title>
    <author>J K. Rowling</author>
    <year>2005</year>
    <price>29.99</price>
  </book>
</bookstore>

I am using BaseX 7.9. When I request attributes,

for $book in collection()/bookstore/book
return $book/@*

an error occurs:

[SENR0001] Attributes cannot be serialized: attribute category {"COOKING"}.

How can this be fixed? Thanks for helping me!

1

There are 1 best solutions below

1
On

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.

This was different in earlier versions of the specification, which did not allow attributes to be output on their own (see the error code SENR0001 for more information).