-
-
Notifications
You must be signed in to change notification settings - Fork 180
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] xml-to-json() ignores namespace requirement #5543
Comments
Error in Saxon:
Error in BaseX:
The QT3 test suite contains a test for this condition, but the addition of this function to eXist predated the integration of the test runner with eXist's CI. In addition, some of the tests for this function in eXist lack the required namespace on the tested elements. I think the fix is likely to update the conditions here - https://github.com/eXist-db/exist/blob/develop/exist-core/src/main/java/org/exist/xquery/functions/fn/FunXmlToJson.java#L77-L79 - to include a check for the namespace of the element. |
The important part of the spec is the definition
In the schema definition
Furthermore, we have:
And the error is defined:
The problem now arises from the fact that the rules and definitions contradict each other: The definition for A schema identical to the one quoted without defining the fn-namespace as targetNamespace would still contain the type definition of There is, though, no defined way how the data are to be processed (as that requires the namespace) and an error – well, the error and the definition still contradict each other… Hence, I suggest to discuss this issue in the context of how the spec should be phrased as the real intention is not really clear (in all practicality, if a nodetree validates against the schema but for being in the fn-namespace, no actual problem would arise). |
I am puzzled by the phrase, in the last sentence above, that "the real intention is not really clear". I don't have a lot of experience parsing the language of specifications, so perhaps there is a genuine uncertainty about intention that only my own inexperience prevents me from recognizing, but I don't see any ambiguity at all about "the real intention": the citation I reproduce from the spec says plainly that the elements to be converted from XML to JSON by the With that said, I agree that the current QT4 revision of the specs provides an opportunity to revisit the wording where it might lead to confusion—not because the real intention is unclear, but because the language may not be as clear as the intention. |
The catch is in the contradiction I pointed out – the definition of I’d like to also draw your attention to one word in your first quote: “typically”. Also, when processing: as long as the data types match, there is nothing that precludes a node tree from being parsed – that might well be the reason for the simplified “validation” that is described in my quote above (by requiring the type annotations to match without recurring to the fn-namespace). These last 2 points together allow for the interpretation that the intention might have been to allow such a node tree to actually be an acceptable (“is considered valid”) input with the more restrictive text simply having been copied from the definition of the inverse function. That’s the reason for my claim that the intention is not completely clear. |
During today's Community Call:
|
Describe the bug
The description of the
xml-to-json()
function in the XPath and XQuery Functions and Operators 3.1 spec states that:That definition says that:
The
xml-to-json()
function in eXist-db transforms XML map and array markup to JSON even when the namespace is omitted. <oXygen/> raises an error if the XML elements to be transformed are not in the required namespace.Expected behavior
I expect eXist-db to raise an error if the XML elements to be transformed by the
xml-to-json()
function are not in the required namespace.To Reproduce
Create the following XQuery and run in eXide and in the <oXygen/> XQuery debugger. It will succeed in both. Then remove the namespace declaration and rerun. The code will succeed (incorrectly) in eXide and raise an error (correctly) in <oXygen/>:
Context (please always complete the following information)
Build: eXist-6.2.0 (c8fa495)
Java: 1.8.0_333 (Oracle Corporation)
OS: Mac OS X 12.7.6 (x86_64)
Additional context
conf.xml
?: NoThe text was updated successfully, but these errors were encountered: