I work on a medium sized project that has a central XML schema defining what types of XML documents the system will be able to process. There are about 800 of these documents, and many of them are very large.

The schema itself has evolved over the years and comes in several versions. Each document clearly indicates within the markup what schema version it is targeting.

In order to keep the schema clean, I want to know what features of the schema are no longer in use. E.g. "Complex type A appears 3 times across 2 documents". So that I can remove those features in future versions with minimal impact. I'm hoping for a python script, but a packaged software solution could be useful too, or something in a different language is fine. I can split the sets of files by schema version myself if needed, so the minimal requirements would be:


  • One schema file
  • One or more xml files that are valid according to that schema


  • How many times, and in how many files, each schema type is used
  • Format does not matter, csv, python dictionary, all good as long as it is structured.

1 Answer 1


The Saxon schema processor has an option -stats:filename which outputs information about which schema components were used during a validation episode, and how often. Unfortunately it doesn't tell you which components were NOT used; for that you need to do some further processing of the output. A "validation episode" here can be processing a single XML file or multiple XML files.

See http://www.saxonica.com/documentation/index.html#!schema-processing/commandline

I have to confess I haven't used this feature for quite a while and I don't know how well tested it is.

You'll need to get yourself a license for Saxon-EE -- a free 30-day evaluation license is available.

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.