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

[xq31] Why don't json-to-xml() and xml-to-json() process JSON as item() ? #34

Open
Reino17 opened this issue Dec 10, 2021 · 2 comments
Open

Comments

@Reino17
Copy link

Reino17 commented Dec 10, 2021

https://www.w3.org/TR/xpath-functions-31/#func-json-to-xml:

fn:json-to-xml($json-text as xs:string?) as document-node()?
[...]
json-to-xml('{"x": 1, "y": [3,4,5]}')

Why has it been decided to have this function accept the JSON as xs:string?
Intuitively, without reading the documentation, I would've entered json-to-xml(map{"x":1,"y":[3,4,5]}). It's in the name after all.

https://www.w3.org/TR/xpath-functions-31/#func-xml-to-json:

fn:xml-to-json($input as node()?) as xs:string?
[...]
The input <array xmlns="http://www.w3.org/2005/xpath-functions"><number>1</number><string>is</string><boolean>1</boolean></array> produces the result [1,"is",true].

Why has it been decided to have this function put out the JSON as xs:string?
Intuitively, without reading the documentation, I would've expected xml-to-json(<array xmlns="http://www.w3.org/2005/xpath-functions"><number>1</number><string>is</string><boolean>1</boolean></array>) to put out [1,"is",true] as item() (like parse-json()). It's in the name after all.

Why is XML processed as (document-)node(), but JSON not as item()? This...

fn:json-to-xml($json as item()?) as document-node()?

fn:xml-to-json($input as node()?) as item()?

...would've been much more obvious to me.

@michaelhkay
Copy link
Contributor

michaelhkay commented Dec 10, 2021 via email

@Reino17
Copy link
Author

Reino17 commented Dec 10, 2021

Thanks for the clarification. Can I then turn this into a request for XPath/XQuery 4.0?

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

No branches or pull requests

2 participants