Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple XSD schema files to C# classes

Tags:

c#

xsd

What is the best way to generate C# classes from multiple XSD schema files?

Some XSD schema files may have dependency to the other, I am trying to avoid duplicated C# classes being generated.

like image 749
Ray Lu Avatar asked Jul 16 '09 21:07

Ray Lu


1 Answers

Use the XSD.EXE program, but pass all of the schemas to the program on the same command line.

For example:

> xsd /c qbxmltypes130.xsd QBUqbxmlops130.xsd QBUqbxmlso130.xsd QBUqbxml130.xsd 

Will emit a class named:

qbxmltypes130_QBUqbxmlops130_QBUqbxmlso130_QBUqbxml130.cs 

In this case these are Quickbooks Desktop SDK xsd files, and the final file has types it depends on in the first 3 files. It won't emit on its own, but with its dependencies it works as desired.

Note that there is a /parameters:<file> switch that allows you to specify a file of command line parameters. I remember using it in one project for a similar reason.

XSD.EXE doc has the parameter format.

like image 65
John Saunders Avatar answered Sep 20 '22 10:09

John Saunders