Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] few functions not according to spec #3594

Open
dizzzz opened this issue Oct 29, 2020 · 4 comments
Open

[BUG] few functions not according to spec #3594

dizzzz opened this issue Oct 29, 2020 · 4 comments
Labels
discuss ask for feedback

Comments

@dizzzz
Copy link
Member

dizzzz commented Oct 29, 2020

I compared the cardinality of all (w3c defined) functions in eXist-db with the spec; I found a few differences:

eXist=contains-token#3 xs:string* xs:string xs:string? xs:boolean 
Specs=contains-token#3 xs:string* xs:string xs:string  xs:boolean

eXist=json-to-xml#1 xs:string? item()? 
Specs=json-to-xml#1 xs:string? document-node()?

eXist=json-to-xml#2 xs:string? map(*) item()? 
Specs=json-to-xml#2 xs:string? map(*) document-node()?

eXist=xml-to-json#2 node()? map(*)? xs:string? 
Specs=xml-to-json#2 node()? map(*)  xs:string?

Can these be fixed in 5.x or are these typically 6.x items?

@dizzzz dizzzz added the discuss ask for feedback label Oct 29, 2020
@joewiz
Copy link
Member

joewiz commented Oct 30, 2020

@dizzzz I left some notes about this in #1929. Most notably:

But the fixes to contains-token, json-to-xml, and xml-to-json should definitely be made and I don't see any problem in making these 5.x fixes.

(By the way, I think your results might be flipped: what you say is the spec appears to be eXist's current behavior, and vice versa. For example, the specs say that fn:collection#1's parameter is xs:string?, not xs:string* - the latter is eXist's current behavior.)

@dizzzz dizzzz closed this as completed Oct 30, 2020
@joewiz
Copy link
Member

joewiz commented Oct 30, 2020

@dizzzz Your observations about the signatures of contains-token, json-to-xml, and xml-to-json are still valid. Shouldn't we keep this issue open until those issues are fixed?

@dizzzz dizzzz reopened this Oct 30, 2020
@lcahlander
Copy link
Contributor

This code

xquery version "3.1";

fn:json-to-xml(fn:serialize(fn:json-doc(file:///Users/lcahland/Desktop/foo.json, map {
    "liberal": fn:true(),
    "escape": fn:true()
}), map {
    "method": "json"
}), map {
    "liberal": fn:true(),
    "escape": fn:true()
})

with the JSON document:

{
    "operandRight": {
        "type": "literal",
        "dataType": "code",
        "value": "\u0000"
    }
}

returns the following from Saxon

<?xml version="1.0" encoding="UTF-8"?>
<map xmlns=http://www.w3.org/2005/xpath-functions>
   <map key="operandRight">
      <string key="dataType">code</string>
      <string key="value" escaped="true">\\u0000</string>
      <string key="type">literal</string>
   </map>
</map>

And this from eXist-db 6.0.1. The value in <fn:string key="value"></fn:string> is a unicode 0x0 and will not store in the database

<fn:map xmlns:fn=http://www.w3.org/2005/xpath-functions>
  <fn:map key="operandRight">
    <fn:string key="type">literal</fn:string>
    <fn:string key="dataType">code</fn:string>
    <fn:string key="value"></fn:string>
  </fn:map>
</fn:map>

@line-o
Copy link
Member

line-o commented Nov 16, 2022

@lcahlander The issue valid but does not have to do with cardinalities. I would suggest to open a separate issue for your finding and rename this issue to mention built-in function cardinality explicitly.
My fear is that we will forget to fix your issue when it is in here and other may also not find it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discuss ask for feedback
Projects
None yet
Development

No branches or pull requests

4 participants