My approach to this was to canonicalize the representation of an XML schema.
Unfortunately, I can also tell you that, unlike canonicalization of XML documents (used, for example, to calculate a digital signature), it is not so simple or even standardized.
So basically you have to convert both XML schemas to a “canonical form” - no matter what tool you create or use, thinks that form is, and then do a comparison.
My approach was to create a set of XML schemas (maybe more than one file if you have more namespaces) for each root element that I need, since it was easier for me to compare XSDs created using the style of the Russian doll, starting with the PSVI Model .
Then I used options such as members of the auto-substitution substitution group, as well as the replacement of substitution groups to choose from; removal of "unnecessary" XML schema sequences, folding options with one option or moving minOccurs / maxOccurs around for individual composer elements, etc.
Depending on which features of the comparison tool are XSD-compatible, or you plan to build, you may also need to reorder particles under composers such as xsd: choice or xsd: all; etc.
In any case, what I learned after all this, it was very difficult to create a tool that would work for all the “cool” XSD functions there ... One test case, which I remember with love, concerned various xsd: any content.
I really wonder if things have changed since then ...
source share