wrong element is used if a ref="elementName" is not unique#85
wrong element is used if a ref="elementName" is not unique#85waldi5001 wants to merge 3 commits into
Conversation
To fix issue 80, it is not necessary to check for min/maxOccurs. The underlying issue is the duplicate objects in the concreteElementsMap. These duplicate objects are the result of initialising the includedElements list.
When an element is referenced using `ref`, no distinction is made as to whether it is a child of a schema or of another type. All implementations of `clone` write directly to the `placeHolderAttributes` passed to the method. To prevent the caller’s own `placeHolderAttributes` from being altered, `clone` creates a copy of the argument passed to it. refactor element lookup in replaceUnsolvedReference The logic is as follows: if the element is a child of a Redefine, replace it with the original element. Otherwise, if a Redefine is available, replace it with that. In this case, the UnsolvedReference points to a Redefine. In the latter case, all elements with a schema as parent are considered. If UnsolvedReference is a TypeRef, the element must be a Simple or Complex Type. If it is not a TypeRef, it must be an ElementRef. open some usefull methods with protected to give the ability to overwrite eventual bugs.
If an http(s) URL is specified in an include, it does not need to be
‘normalised’ in the same way as a file.
on Linux "new File("/a/folder", "http://a.url/issue_25_amzn-base.xsd");"
doesn't throw a IOException. An attempt was therefore made to normalise
the file "a/folder/http://a.url/issue_25_amzn-base.xsd" which of course
did not work.
|
Thanks again for the PR, I've accepted the other one and merged it to master. I was a bit confused with the redefine element and how it worked and I've added some more tests and adapted your PR a bit with Claude. I've added a great deal of validations that ensure stricter compliance with the XSD specification, and made some adjustments related with path/URI handling that you mentioned in the other PR that should address differences between Windows and Linux. I've published a new version with all of the changes, 1.2.23. If you find anything else let me know. |
|
Hello @lcduarte, I’d like to thank you. I’ve tested your implementation against mine and everything looks very good. Your changes and those made by Mr Claude are quite extensive, and I’d like to say a few words about them. In principle, I’m not opposed to the use of AI, and in this particular project, it can certainly save a fair bit of typing, given that the main task is essentially to translate the specification into code. During the review, however, I noticed that Mr Claude is rather verbose, which makes the code harder to read and understand. I’d also like to point out that the Java XML parser already handles quite a bit of validation, which may now be implemented twice. I’ll continue working on this project because I really enjoy it and feel I can make improvements. I still have at least one bug I’d like to fix and make available. |
|
@waldi5001 I completely understand, most of the work was to fix gaps between the specification and the code, which for a while has been the cause of the issues that were being open. This happened because at the start of the project it was mostly to fit my needs and I never researched the specification in order to identify gaps, and at this point in time I'm more of a stranger to XSD than whoever opens an issue or a PR in this repository, so it was either AI assisted or continue with the issues as is. In the future I'll probably try to make one more iteration to include some more missing elements for the XSD 1.0 spec, or even maybe the newer 1.1 spec. It depends on my availability and will. |
Whilst investigating my issue, I came across #80 / #79 and realised that the author @HennoVermeulen had likely made a mistake. He had written a workaround for the issue of duplicate objects. I fixed this problem in my first commit.
In my actual commit, I noticed that every call to clone modifies the oldElementAttributes. If there were still duplicate objects from the previous commit, this would cause side effects that I encountered whilst investigating this commit. Hence the commit before this. To prevent this problem in principle, I allways create a copy of the map in XsdAbstractElement
Finally, I noticed that all the tests run perfectly on Windows, but not on Linux. Specifically: testIssue26_Includes and testIssue25AutoAccessory. I ‘fixed’ this problem quite easily.
As noticed in #83 not in all situations all tests run, so I have to refactor the element lookup in replaceUnsolvedReference. The logic is as follows: if the element is a child of a Redefine, replace it with the original element. Otherwise, if a Redefine is available, replace it with that. In this case, the UnsolvedReference points to a Redefine. In the latter case, all elements with a schema as parent are considered. If UnsolvedReference is a TypeRef, the element must be a Simple or Complex Type. If it is not a TypeRef, it must be an ElementRef.
at the end, I open some usefull methods with protected, to give the ability to overwrite eventual bugs.