When I try

xml-to-json(
  <map xmlns="http://www.w3.org/2005/xpath-functions"; key="root">
    <number key="n">2</number>
    <string key="foo">a</string>
    <boolean key="checked">true</boolean>
  </map>,
  map { 'indent' : true() }
)

with BaseX 8.6.5 I get an error "[FOJS0006] Element 'map' must have no key.".

Saxon 9.8 however parses that input fine.

Looking at https://www.w3.org/TR/xpath-functions-31/#func-xml-to-json there is some text saying "An element node E having a key attribute and/or an escaped-key attribute provided that E would satisfy one of the above conditions if the key and/or escaped-key attributes were removed." which sounds as if a "key" attribute should or could be ignored.

Or is BaseX schema-validating the argument and that way ("Otherwise, the processor may attempt to validate the element against the schema, in which case it is treated as valid if and only if the outcome of validation is valid.") the "key" attribute is not allowed?

It seems the spec that way allows some confusing lack of interoperability.

Reply via email to