tags:

views:

656

answers:

2

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.

Thanks

+4  A: 

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

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 param format.

John Saunders
+4  A: 

I for one found the examples in the MSDN doc a bit lacking. Here's an example parameters file for the issue codemeit described:

<xsd xmlns='http://microsoft.com/dotnet/tools/xsd/'&gt;
<generateClasses language='CS' namespace='Namespace.subnamespace'>
 <schema>FirstSchema.xsd</schema>
 <schema>AnotherSchema.xsd</schema>
 <schema>LastSchema.xsd</schema>
</generateClasses>
</xsd>
anony mouse
Thanks, @anony_mouse -- I was looking for a good example of that syntax!
ewall