I have a task to import 30 different types of XML-documents into a database. The data should be stored in a way that the XML files can be easily generated from the database.
For each different type of XML-document, I have an XSD, with some included common XSD-documents. The XSD-files are nested (1.xsd includes Common1.xsd which includes Common2.xsd etc). The XSD-files contains both SimpleType- and ComplexType-definitions.
I'd like to avoid handcrafting the DDL and instead have the DDL generated from the XSD-files. Does anyone have experience from doing that?
Here's an example on how it could look.
It should be possible to write a CLR assembly which will process the XSD using some XSLT or T4 implementation and generate appropriate DDL.
Unfortunately in case of your XSDs, you have `` elements in the sequences so the XML file based on that XSD can have more attributes than defined in the XSD. So you are not able to generate the DDL only from XSD to be able to import all XML files based on that XSD as each of that XML can have different set of attributes.
So in that case to generate a proper DDL you will need XSD and also an XML file to be imported. Then you should validate the XML that it matches the XSD and then generate the DDL based on XSDs and XML. For sure possible but probably a lot of coding in .NET (C# or VB.NET).
There is also a XSD2DB project on SourceForge which is a command line utility which is able to convert Microsoft ADO.NET compatible DataSet Schema File (XSD) into a DDL. But your XSDs seems not to be a ADO.NET XSDs. And especially as I have mentioned the biggest problems are the elements.
answered Jan 16, 2012 at 02:14 PM