Get a valid schema of large (1 GB) xml files

sql sqlbulkcopy sqlxml xml xsd

Question

I need to bulk load huge xml files to SQL Server 2005. I decided to use SQLXMLBULKLOAD in my C# app, but I need to get valid xsd-schemas of those xml files to load them. Which is best way to generate xsd file? I tried MS VS xsd.exe, but it tries to load the file into memory, which causes OutOfMemory exception.

Thanks!

Accepted Answer

Strip the file down to create a smaller one that is representative of the whole, then generate an XSD from that. You can then tailor the result if necessary.


Popular Answer

There are quite a few tools to generate schemas from instances, but I don't know how many of them are able to operate in pure streaming mode. One tool which will work regardless of the file size is the DTDGenerator that was originally part of Saxon; you can find it here:

http://saxon.sourceforge.net/dtdgen.html

It produces a DTD rather than a schema, but there are plenty of tools available to convert a DTD to a schema.



Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why