I was tasked with migrating an xsd generation tool to something new. But since the XSD's are part of a publicly published interface they should not change.
The new tool does things a bit differently, so when comparing the xsd's with a text diff tool I get a lot of differences, for example the order of global elements is different, order of enumeration tags is different, etc...

Anyone know a tool (or a method -> I do write code) that can compare XSD's functionally, ignoring changes that do not change the content of the XSD?

And since I have a lot of XSD's to compare (about 740 in total) I would prefer a tool that could do them all at once and then give me some kind of report with the details.

  • Instead, I would produce a bunch of XML files depicting what happens in your live application and validate them towards your 2 schemas. Or more precisely: create test XML files that validate under the old schema, then verify they validate to the new one. This will have various benefits, far outside of the specific XSD problem, but also I think it is more relevant to test stuff as they happen instead of XSD "purity" or "correctness" as they are often multiple way to do the same thing. Jan 12, 2018 at 17:47
  • @PatrickMevzek Thanks for the suggestion Patrick, but I'm afraid there are just too much possible variations of xml files to validate them all. Another problem is that one of the requirements is that the XSD's themselves are the same, meaning they have the same structure, names, files, etc... The idea is that the companies that use these XSD's in their systems don't have any development work due to the switch from the old to the new system. Jan 13, 2018 at 7:23
  • Have you tried outputs of the XSD files using XML canonicalization rules? This should ensure orders and things like that, making comparison possible. In fact, it is even the only sane way to compare two XML files, and XSD are XML files. See w3.org/TR/xml-c14n and search for "C14N" in your tools (editors and XML libraries). Jan 13, 2018 at 20:12

3 Answers 3


To summarise, addressing your requirements:

  1. Comparison tool that can compare XSD files: Yes
  2. Can identify changes in structure, not just content of XSD files: Yes
  3. Can ignore expected changes: Yes
  4. Orderless comparisons; avoiding false positives from moved elements: Yes
  5. Compare all files at once: Yes, through batch processing
  6. Produce a report with the details: Unclear what is needed here

XML Compare, developed by DeltaXML, is a structurally aware XML comparison tool that is able to identify change in both the structure and the content of XML files, including XSD.

In instances where elements have moved in the file but the order of said elements is not significant to the comparison, XML Compare has built in functionality for Comparing Orderless Elements. This can be customised extensively using XSLT as needed.

When you are expecting changes that do not need to be identified as change, you can use XML Compare's built in Ignoring Changes functionality which can again be customised using XSLT.

For bulk processing of your files, although XML Compare only compares files 1-to-1, it can be run via the command line, REST API and Java API. This means that by writing a batch file to queue up comparison operations, or if you use the REST API the comparison operations will be queued automatically.

Finally, to address your need for a report summarising the results, this depends on what you mean. XML Compare is capable of producing HTML reports from diff outputs that highlight changes in-line or side-by-side. It sounds however like you may be looking for a more statistical report on the results of the comparisons, for which XML Compare does not currently have a facility. It is worth noting however that the diff outputs produced by XML Compare are valid XML, and can be readily processed to identify the change attributes in the file.

Disclosure: I am an employee of DeltaXML.

  • 1
    Thanks Oliver. While I finished this task a few years ago by writing my own comparer (based on an existing library) I'm sure a future reader might benefit from your answer. Oct 17, 2022 at 17:14

That's quite a challenge, because so many differences are possible: you may have to make compromises depending on what you actually encounter. (For example, you may or may not need to bother with named model groups, depending on whether either of the schemas you are comparing actually uses them. Most schemas don't.)

If I were doing this (and of course I'm biased towards using my own tools) I would start by using Saxon's schema validator to generate SCM (schema component model) files for both schemas. This will do a fair bit of normalization, e.g. handling the difference between inline types and references to named global types. I would then write an XSLT stylesheet to do further normalization on the SCM files, for example sorting components into a canonical order, sorting enumeration values, and so on; also, eliminating the parts of the SCM files that aren't relevant, such as finite state machine details. I would then probably write a custom XSLT comparison module to compare the two normalized SCM files (along the lines of https://dvcs.w3.org/hg/xslt30-test/file/tip/runner/compare.xsl which is used for comparing XSLT test results) - the key being that you don't just want a boolean answer saying whether they are the same or different, you want to highlight the differences. Alternatively you could use fn:deep-equal to test whether they are the same, and then using a visual diff tool to examine them side-by-side if not.

  • Thanks Michael, that is useful input. I'm still hoping to find a more out-of-the box solution as we will need to compare the files only once. Jan 12, 2018 at 13:27

EDIT: A decent editor I started using recently is Oxygen XML Editor. It can diff both XML and XSD files. I'm not sure if there's a way to batch the diff.

I have a project I wrote to perform programmatic Semantic Equivalency for Xml, based on work from @eric-white Eric White formerly from Microsoft. I just have to dust it off, probably make some updates, and post it to GitHub here: https://github.com/udlose/xml-equivalency

I will update this post once the code has been posted.

  • I only saw a license and readme file, committed 7 years a go. Did I miss something? Feb 8 at 17:34
  • @GeertBellekens no, you didn't miss anything. As I mentioned, I need to dust it off and post to the repo I created 7 yrs ago lol. I pulled the code off an old USB drive last night and will try to work on getting it updated again this wkd. I apologize for any delay/confusion.
    – Dave Black
    Feb 9 at 14:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.