-
Notifications
You must be signed in to change notification settings - Fork 10
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
Enable recursive XSD adding text output compare (as JavaFX is not working) #10
base: develop
Are you sure you want to change the base?
Conversation
Thanks already for the draft, seems very promising. |
Added some missing facets to comparison including test documents to compare changes (1/2)
and improved the reporting and added real-world test documents - the factur-x subset XSDs. My original use case was to check if the UN/CEFACT XSD D22B has added new constraints like:
What might be missing:
|
Finally, I have done some further programming of improvements:
I could not find xs:assert nor xs:explicitTimezone in my XSDs (UN/CEFACT XML and UBL) neither could I find "explicitTimezone" with a grep within Xerces sources, therefore I am fine not embracing them now. Guess, I am ready now :-) |
I have examples for the missing features in a comment of a test file.
|
After being finished with comparing the UN/CEFACT XML, I added a test for comparing UBL 2.1 with UBL 2.3. Unfortunately, this test fails due to acquisition of too much Heap space (tried increasing Heap in IntelliJ without success). It seems that for UBL the extra DOM-like element model that xsd-compare is creating is too much. Nevertheless, the comparision for UN/CEFACT XML worked (and this was my main goal) and I have learned a lot of the underlying Xerces API and the problems that occur when comparing XSD grammars. Thanks again for your nice project, Yoep! Best regards, |
PS: Realized that the change of element content was not compared (added it) |
Something that I think might be better is to move the CLI functionality to a CommandLineRunner. If you want, I can do this after the PR merge and I'll foresee some new Github actions integrations to generate installers for all Operating Systems. |
Yes, please do so! If I will find further problems in XSD compare in the past weeks (e.g. by the work on Factur-X e-invoice standard), I will continue to iterate/enhance the comparison! Last but not least, I am usually using the Apache 2 License (as Xerces) as it allows to copy source code functionaltity in other Apache sources of "mine", e.g. https://github.com/tdf/odftoolkit/. |
Thanks about the remark of the license (forgot about it), I've updated it to Apache 2.0. I'll first make sure the packaging is working for all OS systems before I do some work on the refactoring. |
</transformer> | ||
</transformers> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin>--> | ||
<plugin> | ||
<artifactId>maven-assembly-plugin</artifactId> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if it has to do with the new packaging plugin, but running the bundled jar doesn't seem to be working.
➜ xsd-compare git:(feature/recursive_xsd) ✗ java -jar ./target/xsd-compare-0.0.9-SNAPSHOT-jar-with-dependencies.jar --gui
usage: java -jar xsd-compare-jar-with-dependencies.jar <opts> <old-xsd-grammar> <new-xsd-grammar>
options:
--ui: omits the GUI and returns only a text result for comparision (default).
--gui: starts a JavaFX GUI front-end for comparison.
--multi or -m: multiple lines indented per change sorted by XSD change. (default).
--single or -s: one single line for each change with XPath in the start, harder to read but easier for compare the output with other tools.
--extensions-only or -e: one single line for each extension of the grammar sorted by type. Restrictions/limitations are being neglected.
--restrictions-only or -r: one single line for each new restrictions, requirements or limitations of the new grammar sorted by type. Extensions are being neglected.
--help or -h: this help text.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may try to get packaging and frontend to work before my patch. At least did not work for me. Thanks for your help!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am usually testing/starting directly from the IDE and not triggering by commandline the JAR, but tested it once manually, when I was added the functionality (at least the xsd-compare-0.0.9-SNAPSHOT-jar-with-dependencies.jar)
Calling the following is showing me the options:
java -jar xsd-compare-0.0.9-SNAPSHOT-jar-with-dependencies.jar
With the former way, I had problems with the manifest...
You might considere to increase the JDK baseline to JDK 17 (or at least play around / test it ) for the JavaFX part?
Where are you hanging? Perhaps you start on a branch from scretch without any funcationality of mine from your latest commit before my PullRequest. Updating the pom.xml (not trivial - I have realized) :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there are any question/remarks left to answer, please give me a ping, Yoep!
All the best,
Svante
I tried variations on log and packaging, but logging never worked for me in a file) and packaging updates can be ignored as well as I never was able to get rid of exceptions. Therefore you might ignore or questions such changes. Sorry for any confusion and thanks for the license update 🤗 |
I have updated an updated of the UN/CEFACT XSDs and relalized a mistake I made with the report of new restrictions and extensions of the XSD grammar in regard of enumerations. |
BTW many thanks for the license change. With the commit the master branch has now appeared in public on GitHub and I might try to rebase this PR develop branch with te master branch (adding my mentioned reporter updates for enumeration fixes on top). |
Hi yoep, I rebased my changes with your Apache licence change, which happened after my fork, so it is now shown on top of my changes. In addition, I have pushed the enumeration report update (taking concern of the edge cases of adding/removal of an extension. Where "adding of an enumeration"=="grammar restriction" and "removal of an enumeration"=="grammar extension". Aside of these edge cases a larger enumeration means always an extension and a smallar a grammar restriction. |
…mm to loop, resulting into StackOverflow
…ntrolled by a map)
…, modifying and deletion initally working (to be further tested)
…th request to update in case of program change within assertion
…capsulating a change (add,modification,removal) into the Change (former Modifications) class - this will ease adding further other text reports
…gered by regression tests)
… backwards compatibility
…of choice does correctly not activate choice)
…clusive xs:totalDigits xs:fractionDigits with test cases. Fixing/Refactoring OnlyNewRestrictionReport and OnlyNewExtensionReport
…new single enumeration is equal to the previous fixed value or a removed single enumeration is still provided as @fixed attribute. Finally, moving new enumerations from extensions to restrictions reports, e.g. as a given domain (e.g. Strings) is being restricted to the subset of the enumeration of values
… it on the fly 2) Number of recursions can be set by default three. The higher the more possible XPaths and XsdElements are being created
… with new versions
…ry change and enumeration null vs empty disabling (for later)
…values) is a restriction and equally the removal of an enumeration is an extension. Aside of these edge cases, a larger enumeration is always an extension and a smaller a restriction of the grammar.
ef39882
to
f511016
Compare
Dear Yoep, I have rebased this pull request as you updated the sources last week! :-) Could you merge them? Or is there something that still could be done?` From my perspective: The command line worked well when comparing the quite big UN/CEFACT XML grammar version D16B with D22B! Would you like to test it with the GUI? Might be already quite big! Have a nice holiday season, Yoep! Greetings from Germany, |
Hi Svante, Thanks for updating the feature branch. If it works, I'll merge it in. Happy holidays for you too :) Kind regards, |
… version - adjusting regression tests due to changes
…est variables accordingly to allow further Factur-X versions in the future
…endings to Linux \n
Dear Yoep,
Thank you for your project it gave me a very good kick start on the Xerces Java API!
(BTW I was able to build and debug thourgh Xerces in conjucntion with xsd-compare in IntelliJ using JDK 8 after adding some HTML interface).
The features of JavaFX, spreadsheet and native packaging have not been working for me from the start on my Ubuntu 22.04 LTS (Jammy Jellyfish) with OpenJDK 11 (nor on Windows 10). I tried to update to all latest dependency versions, but as JavaFX is released in parallel with JDK, perhaps an update of the project to the JDK 17 LTS - as it is a stand-alone comparison tool this should be unproblematic. But as I am fine with text output for the comparison I don't follow this any longer.
Still this update caused some changes in the spreadsheet and JavaFX classes.
Also I did some renaming, mainly according to XSD spec and Xerces, sometimes due to refactoring, e.g.
Renamed Modifications.java to Change.java as it now represents either an Add, Modfication or Removal change.
A modification change might stilll consist of the change of several XSD facets but it is seen as a single change of either an element or attribute.
BTW it helped me to read the abstract XSD data model chapter in the W3C XSD spec (and jump back there from time to time)
With this PR I have enabled the feature of recursive XSDs like the on from UN/CEFACT XML:
My test case was the compare of the cross industry invoice (CII) XML of the second release (B) of 2016 -> D16B (used by the EU norm for e-invoices EN16931 - where I am a CEN co-editor) with the second release (B) of 2022 -> D22B currently a Beta
I am returning the comparison as a list of changes, which an be serialized to text by using a different TextReporter.
I am using two different text outputs (both being serialized to txt files by JUnit tests to ./target)
see https://raw.githubusercontent.com/svanteschubert/xsd-compare/develop/src/test/resources/references/comparison-CII_D16B-with-D22B.txt
see https://raw.githubusercontent.com/svanteschubert/xsd-compare/develop/src/test/resources/references/comparison-CII_D16B-with-D22B_singleLined.txt
You may find for both new added automated regression tests.
Note in the multi-line output, that the type change in the XSD is the first line (for modifications also the second indented lines), which I call Header Lines, as they exist once for multilple XPath.
A single type change might effect many different named nodes accross valid documents of the XSD grammar. Therefore may one header line have many XPath (a HashSet of XPath as body lines).
In the end I have the following statisik:
**** STATISTIC ****
** ELEMENTS
Added elements in XSD: 98
Added elements in XML: 1828
Modified elements in XSD: 18
Modified elements in XML: 175
Removed elements from XSD: 6
Removed elements from XML: 45
** ATTRIBUTES
Added attributes in XSD: 5
Added attributes in XML: 10
Modified attributes in XSD: 52
Modified attributes in XML: 2352
Removed attributes from XSD: 141
Removed attributes from XML: 8703
I might continue after eastern to check completness and might add tests for cases where xs:choice, xs:sequence, xs:all is being changed. But perhaps you are curious why the JavaFX is not starting any longer and might give it a quick check.
Perhaps as I started to do updates switch to JDK 17. :-)
BTW the maven-shade-plugin did no longer work (for me) so I switched to maven-assembly-plugin creating a jar-with-depencies. Still I got troubles moving version, buildtime into the manifest as I am doing at other projects:
https://github.com/tdf/odftoolkit/blob/master/odfdom/pom.xml#L136
allowing that a "java -jar XY.jar" returning version information, I even use usually the last commit hash. ;-)
Anyway, this is therefore a draft PR as I am uncertain if I broke existing features (as they never worked for me from the beginning), nevertheless the recursive grammar and the refactoring are worth a review IMHO.
If you are like to share a remote tea, I would happily explain in more detail what I intended and where I would like to have some feedback from you :-)
All the best and Happy Eastern holidays (even if we might have different religions there should be always a reason to celebrate) :-)
Svante