Multiple xsd's with the same includes

Dec 17, 2008 at 1:00 PM


I received a few nice xsd files which I want to convert to classes (using this Xsd2Code) All the xsd's have the same includes, like this:

<xs:include schemaLocation="kstypes.xsd" />
<xs:include schemaLocation="ksparams.xsd" />

When I generate a class for each xsd the types declared in these files are duplicated for each original xsd. Is there any easy way to 1) only generate the types in the included xsd's once and 2) make sure all other classes use these types?


Dec 17, 2008 at 7:59 PM
Edited Dec 18, 2008 at 7:47 AM
I'm not sure if I fully understood your question.
I think, the best way is to generate two independent class.
Can you send me an exemple ?
Dec 18, 2008 at 7:56 AM

Example xsd1:

<xs:schema xmlns:xs="">
  <xs:include schemaLocation="kstypes.xsd" />
  <xs:element name="Functie" type="kstypFunctie"/>
  <xs:complexType name="kstypFunctie">
  Example xsd2:
  <xs:schema xmlns:xs="">
  <xs:include schemaLocation="kstypes.xsd"/>
  <xs:element name="GetDetails" type="kstypeDetails"/>
  <xs:complexType name="kstypeDetails">

<xs:schema xmlns:xs="">
  <xs:simpleType name="ksdate">
    <xs:restriction base="xs:string">
      <xs:pattern value="[1-2][0-9][0-9][0-9][0-1][0-9][0-3][0-9]"/>

kstypes.xsd contains shared/common types, used in both xsd1 and xsd2 (and 3 etc). When generating code for xsd1, it generates all classes in kstypes.xsd, and in xsd1. When generating xsd2, all types in kstypes.xsd are generated again. The only way I can use both generated files in a single project is to assign seperate namespaces to both files. This means all common/shared types are declared twice in the assembly, but with a different namespace. This is not what I want :)


Jan 22, 2009 at 1:35 AM
Edited Jan 22, 2009 at 2:58 PM
Have the same problem. We need possibility to generate code for each XSD file separatally without generating types from included schemas.

I created an issue for this problem