shelbaz
shelbaz

Reputation: 97

How to remove unused types in flattened xsd?

So, my issue is the following. I have a XSD file that has an include at the top for another schema. That included schema has another dependency, and so on for a few more files. I decided it would be easier to flatten the xsd file into a single file. I now have a XSD file that is 28,000 lines with many types that are unused. I need to upload the flattened file to something, but it is too large now. I was able to flatten the xml using XMLSpy.

Since the file is so large, I uploaded it here to view: https://filebin.net/m9ldhtty4rkmgixj/FlatRates.xsd

Is there a way to remove all the unused useless dependencies that is not manual?

Upvotes: 1

Views: 663

Answers (2)

Dijkgraaf
Dijkgraaf

Reputation: 11527

I used Visual Studio with the BizTalk 2013 R2 SDK. When you make a minor change and save with that, it offers to remove the unused global types. Unfortunately you do have to tick most of them by hand (although it will tick sub definitions automatically if you tick the parent one). But a lot easier than doing it all manually.

It reduced the xsd from a 1365 KB file to a 562 KB one (still to large to post as an answer).

Upvotes: 0

Michael Kay
Michael Kay

Reputation: 163262

The Saxon schema validator has an options -stats:filename described thus:

Requests creation of an XML document containing statistics showing which schema components were used during the validation episode, and how often (coverage data). This data can be used as input to further processes to produce user-readable reports; for example the data could be combined with the output of -scmout to show which components were not used at all during the validation.

Just a suggestion. That's only one step in the process of course. The schema might be used for other purposes than the validation of that one document. And you will need to do further work to make sure that when you remove a component, there aren't any dangling references to it from elsewhere in the schema.

Upvotes: 0

Related Questions