views:

120

answers:

2

If you have an XSD with an includes reference. Is it possible to generate 2 separate class files. 1 for the XSD, and 1 for the included XSD?

My Scenario 4 XSDs, each of which share 15-20 element definitions in common. Rather than maintaining, I'd like to end up with the 4 XSDs all referencing a fifth file with the common definitions, and code generating 5 .cs files to use.

A: 

No, XSD.exe will generate classes for all imports Try XSDObjectGen. It supports XML include (one level deep, however).

Sheng Jiang 蒋晟
I'm not sure that quite answers my question. Further googling indicates that I can probably achieve the result I want in 1 .cs file by including multiple files in one call to xsd.exe. But I've tried XSDObjectGen and I couldn't make it produce 1 file per source file either, which is what I am after.
Roger Willcocks
A: 

I'm currently hacking xsd2code to provide this functionality. I think linqtoxsd could be extended pretty easily for this as well. The codedom stuff in these makes my head hurt though..

The problem youll run into if you call xsd on each file indivdually, is that each individual output cs file will define all the classes needed to flesh out the base one, thus it will have classes found in the included xsd's. If you do this for mutiple xsd's which all have common include files, you will wind up with duplicate declarations of the code from the includes.

boomhauer
Yeap. Noticed that. So far no alternative to rolling everything into one large file.
Roger Willcocks