There are several ways to handle this, which should provide you some automation at the end; but it all depends on how complex your classes and XSD are.
I would start by using JAXB schemagen against a set of classes that you already have. This may require additional annotations, which you may need to add to your current codebase. With this XSD in hand, you could basically manually compare the two XSDs to see if they are similar. Everything can become complicated if your XSD model uses options, everything, abstractions, groups, etc.
Then I used the XSD tool:
- to generate all the possible XPaths from these two sets for the given root elements, to ensure that you have the same coverage.
- to automatically create XML samples using one of the XSDs, depending on which one is your golden copy, and then check it with the other XSD - detect inconsistencies and also discard the XML code using existing code.
Once Blaise has described marshalling and comparison (ideally use XML that maps to the schema, then an XML representation, text comparison, is likely to be useless).
source share