14

I an xsd file with multiple imports and includes.

I need to basically merge the schema into a single file for use in a third-party application (which does not support includes).

Is there a free/opensource tool or script that can do this?

alex
  • 651
  • 1
  • 9
  • 11
Alterlife
  • 6,557
  • 7
  • 36
  • 49
  • here you may find an [open source solution] (http://rebuildall.umbraworks.net/rebuildall/2011/06/20/Merging_WSDL_and_XSD_files) in c# for merging imports in the calling file. – alex Jul 02 '20 at 10:54

1 Answers1

8

You may find helpful the same that was asked on SO a couple of times, for example here and here. Another free source might be the one described on Microsoft's Technet, as it relates to limitations present in MS SQL Server products (also showing a real life example related to your question), where <xsd:include/>s are not supported. If you don't have the ability to compile and run that code, you can still use it as a "script" with little help from a C# script engine such as this.

However, as I've pointed out here, the <xsd:import/>s cannot be refactored "out" given the limitation where a schema file can only target one namespace.

If you're ever into a really serious refactoring scenario such as the one described here, you may have to consider something else...

Community
  • 1
  • 1
Petru Gardea
  • 21,373
  • 2
  • 50
  • 62
  • I just had to find some example XML, and I was lucky that there was no clash of type names. I was able to copy the component XSD's, push their namespaces to one common name, then cut-and-paste, replacing import lines with the content of the file. This was enough to create a single schema that could be used on http://xsd2xml.com/ to generate an example XML file. Might be a valid compromise for others, so posting it here as an idea. – Steve Hibbert Oct 31 '17 at 08:46
  • @SteveHibbert, the process you described will result in invalid XML. In other words, if the intent is to produce an XML which matches the original schemas, then one would fail at that. – Petru Gardea Oct 31 '17 at 12:08
  • But I have XML from the site, which has given me a start point to begin testing. I agree, it is not correct, but it is a good fudge if your aim is to try to work out a test XML object to throw at a schema. It gets some heavy lifting done, and allows you to work up some XML as a starting point. Case, I have OECD tax schemas that are v. complex, but with this method I at least now have some XML that I can use to get going. You are correct though, mine is not a solution. – Steve Hibbert Oct 31 '17 at 12:14