0

I am using 3 XSD's which I'd like to generate code for in the IDE:

  1. XSD1 is shared data types
  2. XSD2 + XSD3 are both using XSD1 (and extend of course...)

I want to have classes generated for these and due to the shared XSD I could not use the common custom tool since they generate errors of missing types or double types (ambiguity).

Is there a way to achieve this?

2 Answers2

0

If you use xsd.exe on the Visual Studio command prompt you simply include all the schema files in the same request. Then xsd.exe will resolve the common types and ensure there is no duplication.

xsd /c schema1.xsd schema2.xsd schema3.xsd
tom redfern
  • 30,562
  • 14
  • 91
  • 126
  • This is actually the exact same thing I'm currently doing in a pre-build action, what I'm trying to achieve is doing the same within the IDE using a custom tool or something like that. Are you familiar with anything like that – user1037727 Nov 09 '11 at 15:38
  • Not sure what you mean by *a custom tool* – tom redfern Nov 09 '11 at 15:46
0

I assume that by custom tool in Visual Studio, you refer to the feature accessible through the Properties tool window; to quote the context help, it means "a tool that transforms a file at design time and places the output of that transformation into another file[...]".

Your question could be related to this post as well.

What I would do to work around your issues, would be to build a kind of "shim" for your XML Schema files; basically, create an empty XML Schema file, add two import statements pointing to schema 2 and 3 (in your case - the top level ones) and have that file referenced by your custom tool (instead of the ones you have right now). This way, the custom tool will not give you any issues, since it'll look at your files as a set.

Community
  • 1
  • 1
Petru Gardea
  • 21,373
  • 2
  • 50
  • 62