-
Notifications
You must be signed in to change notification settings - Fork 15
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
fn:deep-equal: Order of child elements (unordered-elements) #383
Comments
Thanks for yesterday’s discussion, which helped me to understand how I like @cmsmcq’s suggestion to add wildcard support. The value type could be deep-equal(
<a><b/><c/></a>,
<a xmlns='x'><c/><b/></a>,
options := map { 'unordered-elements': ('*:a', '*:b') } (: 'a', '*:a', 'a:*', '*' :)
) My remaining notes are editorial: A) The option
I was confused by the reference to “child elements”. I would suggest changing it to something like:
B) simple types, complex type, variety, type-annotations, type-variety, typed-values, annotated as… As it’s perfectly possible to implement the function without XML Schema support, I wonder if it’s possible to choose a schema-oblivious wording. In the XQFO spec, the listed terms seem to be exclusively used for |
I am not at all convinced that wildcards would be a useful addition. I think the typical use case for unordered comparison is something like the document at https://learn.microsoft.com/en-us/dotnet/standard/linq/sample-xml-file-customers-orders Here it seems clear that the contents of the I can just about imagine a case for "treat everything as unordered", or perhaps "treat everything except X, Y, Z as unordered". I find it hard to imagine a case where everything in one namespace is ordered, and everything in a different namespace is unordered. If there is, please show me the document. |
I think the quoted document is actually a pretty good example for using a simple wildcard. If someone is only interested in the data, and if the data is well-structured and has no mixed content, there would be no need to expect any node to occur in any particular order. After all, it’s one of the strengths of XPath that the order of an element is irrelevant ( Instead of… map { 'unordered-elements': (
xs:QName('Customers'), xs:QName('Customer'), xs:QName('Orders'),
xs:QName('Order'), xs:QName('FullAddress'), xs:QName('ShipInfo')
)}
(: …or something slightly more compact… :)
map { 'unordered-elements':
('Customers', 'Customer', 'Orders', 'Order', 'FullAddress', 'ShipInfo') ! xs:QName(.)
} …one could simply write Another use case for wildcards are unordered name/value pairs of JSON objects (are any other unordered input) that is converted to an XML representation. The element order may be completely irrelevant. I agree, though, that the name test syntax seems a bit overambitious. |
With the risk of this becoming tedious: Will not this and many other problems' discussion benefit if/when we have the Set datatype in place? The comparison "without regards to order" is nothing else but a set comparison. Trying to implement the properties and functionality of the set datatype every single time they are needed results in obvious redundancy, waste of resources and failure to reach common language and common understanding. |
My objections to introducing a set datatype are that (a) from previous experience, it will take at least 2 years of WG meetings (probably more, since we aren't proposing to have any week-long face-to-face meetings), and (b) that sets depend on a universal definition of equality, and the whole point of this issue is that equality in XML is a very fuzzy concept that needs to be adapted and customised for different user requirements. |
(a) The proposal "[XPath]Proposal to introduce the set datatype in XPath 4" was submitted almost 2 1/2 years ago, on 19th December 2020. If we took it seriously, even by your own estimation, it would already have been produced in final form. (b) Even so, this wouldn't need as many special options as the current fn:deep-equal proposal. If we can do this for fn:deep-equal, we can do it not worse for sets. Let us do at least some serious and important work, not just find justifications to the contrary. We often stumble upon real-life use-cases, the latest was today, raised by Martin Holmes in the general channel of the Xml.com slack Are we here to do something useful, or waste time witlessly? |
@dnovatchev Can we please try to keep the issues clean? I think this is the wrong place to restart the fundamental discussion on sets. If you want to be constructive, you could present an example how you believe a solution based on sets could possibly look like and contrast it with the proposed
The option discussed here would exactly solve Martin’s problem.
You don't consider that proposing a feature only takes 5-10% of the time that needs to be invested to finalize the feature, and that someone needs to invest this time. Next, you seem to want to imply that nothing else happened during the initial proposal. |
I'm sorry, but I would class that as a suggestion, not as a proposal. Adding sets to the data model is likely to involve adding 60-100 pages of text to the specification, not three paragraphs. It takes us about an hour of CG time to agree each page. |
The CG agreed to close this issue without action at meeting 051. |
At meeting 024 where PR #320 was accepted, there remained an open question of how best to specify that in some circumstances the comparisons should be made without regard to the order of (some) children.
Can the name of the option be improved?
Should the option support wildcard names?
The text was updated successfully, but these errors were encountered: