Should xml-to-json ignore a "key" attribute of a "map" root element?

Thursday, 17 August 2017 · 4 messages · last reply 18 Aug 2017
MH
Martin Honnen17 Aug 2017 22:34 #
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.
CG
Christian Grün18 Aug 2017 09:36 #
Quoted text · Martin Honnen · 1 line
> Saxon 9.8 however parses that input fine.
Good to know. Saxon-EE 9.7.0.8, still raises an error, so it seems to have been changed more recently. I will see if there are new test cases that cover this case, or if someone has posted something similar on the Saxon bug tracker.
Quoted text · Martin Honnen · 13 lines
> 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. >
CG
Christian Grün18 Aug 2017 10:06 #
Quoted text · Christian Grün · 23 lines
On Fri, Aug 18, 2017 at 9:36 AM, Christian Grün <christian.gruen at gmail.com> wrote: >> Saxon 9.8 however parses that input fine. > > Good to know. Saxon-EE 9.7.0.8, still raises an error, so it seems to > have been changed more recently. I will see if there are new test > cases that cover this case, or if someone has posted something similar > on the Saxon bug tracker. > > >> 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. >>
CG
Christian Grün18 Aug 2017 10:22 #
Has been fixed; a new snapshot is available [1]. Thanks, Christian [1] http://files.basex.org/releases/latest/
Quoted text · Christian Grün · 34 lines
On Fri, Aug 18, 2017 at 10:06 AM, Christian Grün <christian.gruen at gmail.com> wrote: > Indeed: > > https://www.w3.org/Bugs/Public/show_bug.cgi?id=29917 > https://github.com/LeoWoerteler/QT3TS/commit/b0347f16f25f43fb32271efb115dc0de382cd97f > > Will be fixed soon. > > > > On Fri, Aug 18, 2017 at 9:36 AM, Christian Grün > <christian.gruen at gmail.com> wrote: >>> Saxon 9.8 however parses that input fine. >> >> Good to know. Saxon-EE 9.7.0.8, still raises an error, so it seems to >> have been changed more recently. I will see if there are new test >> cases that cover this case, or if someone has posted something similar >> on the Saxon bug tracker. >> >> >>> 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. >>>

⚡Generated with XQuery