none
create C# classes from xsd schema

    Question

  •  

    Hi,

    I am having problems to generate c# classes from an .xsd schema with the xsd.exe from visual studio 2005. I get this warning: cannot generate classes because no top-level elements with complex type were found. I really cannot find the problem. Can anybody help me?

     

    Here is the code of the xsd schema:

     

     

    Code Snippet

    <?xml version="1.0" encoding="UTF-8"?>

    <!-- edited with XMLSpy v2006 sp2 U (http://www.altova.com) by Kadaster (Kadaster) -->

    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ct="http://www.kadaster.nl/klic/berichtdefinities/2007/08/14" targetNamespace="http://www.kadaster.nl/klic/berichtdefinities/2007/08/14" elementFormDefault="qualified">

    <xsd:simpleType name="AanvangWerkzaamhedenType">

    <xsd:restriction base="xsd:date"/>

    </xsd:simpleType>

    <xsd:simpleType name="BedrijfsnaamType">

    <xsd:restriction base="xsd:string"/>

    </xsd:simpleType>

    <xsd:simpleType name="BeheerderVolgnummerType">

    <xsd:restriction base="xsd:int"/>

    </xsd:simpleType>

    <xsd:simpleType name="BestandsnaamType">

    <xsd:restriction base="xsd:string"/>

    </xsd:simpleType>

    <xsd:simpleType name="DatumType">

    <xsd:restriction base="xsd:dateTime"/>

    </xsd:simpleType>

    <xsd:simpleType name="DatumAanvraagType">

    <xsd:restriction base="xsd:dateTime"/>

    </xsd:simpleType>

    <xsd:simpleType name="DatumOntvangstType">

    <xsd:restriction base="xsd:dateTime"/>

    </xsd:simpleType>

    <xsd:simpleType name="EisVoorzorgmaatregelType">

    <xsd:restriction base="xsd:boolean"/>

    </xsd:simpleType>

    <xsd:simpleType name="EmailType">

    <xsd:restriction base="xsd:string">

    <xsd:maxLength value="70"/>

    <xsd:pattern value="([\.a-zA-Z0-9&amp;_\-])+@([a-zA-Z0-9_\-])+(([a-zA-Z0-9_\-])*\.([a-zA-Z0-9_\-])+)+"/>

    </xsd:restriction>

    </xsd:simpleType>

    <xsd:simpleType name="FaxType">

    <xsd:restriction base="xsd:string">

    <xsd:maxLength value="16"/>

    </xsd:restriction>

    </xsd:simpleType>

    <xsd:simpleType name="GebruikerCodeType">

    <xsd:restriction base="xsd:string">

    <xsd:minLength value="1"/>

    <xsd:maxLength value="20"/>

    </xsd:restriction>

    </xsd:simpleType>

    <xsd:simpleType name="HuisnummerType">

    <xsd:restriction base="xsd:string">

    <xsd:minLength value="1"/>

    <xsd:maxLength value="10"/>

    </xsd:restriction>

    </xsd:simpleType>

    <xsd:simpleType name="HuisnummerToevoegingType">

    <xsd:restriction base="xsd:string">

    <xsd:minLength value="0"/>

    <xsd:maxLength value="15"/>

    </xsd:restriction>

    </xsd:simpleType>

    <xsd:simpleType name="LeveringsVolgnummerType">

    <xsd:restriction base="xsd:int"/>

    </xsd:simpleType>

    <xsd:simpleType name="MeldingsoortType">

    <xsd:restriction base="xsd:string">

    <xsd:enumeration value="Graafmelding"/>

    <xsd:enumeration value="Orientatieverzoek"/>

    <xsd:enumeration value="Calamiteitenmelding"/>

    </xsd:restriction>

    </xsd:simpleType>

    <xsd:simpleType name="NaamType">

    <xsd:restriction base="xsd:string"/>

    </xsd:simpleType>

    <xsd:simpleType name="NetbeheerderType">

    <xsd:restriction base="xsd:string">

    <xsd:maxLength value="128"/>

    <xsd:minLength value="1"/>

    </xsd:restriction>

    </xsd:simpleType>

    <xsd:simpleType name="NotitieType">

    <xsd:restriction base="xsd:string">

    <xsd:minLength value="0"/>

    <xsd:maxLength value="2000"/>

    </xsd:restriction>

    </xsd:simpleType>

    <xsd:simpleType name="OrdernummerType">

    <xsd:restriction base="xsd:string">

    <xsd:length value="10"/>

    </xsd:restriction>

    </xsd:simpleType>

    <xsd:simpleType name="PDFBestandType">

    <xsd:restriction base="xsd:base64Binary"/>

    </xsd:simpleType>

    <xsd:simpleType name="PNGBestandType">

    <xsd:restriction base="xsd:base64Binary"/>

    </xsd:simpleType>

    <xsd:simpleType name="PostcodeType">

    <xsd:restriction base="xsd:string">

    <xsd:minLength value="0"/>

    <xsd:maxLength value="10"/>

    </xsd:restriction>

    </xsd:simpleType>

    <xsd:simpleType name="ReferentieType">

    <xsd:restriction base="xsd:string">

    <xsd:minLength value="1"/>

    <xsd:maxLength value="10"/>

    </xsd:restriction>

    </xsd:simpleType>

    <xsd:simpleType name="RelatienummerType">

    <xsd:restriction base="xsd:string">

    <xsd:minLength value="10"/>

    <xsd:maxLength value="10"/>

    <xsd:pattern value="[0-9]{10,10}"/>

    </xsd:restriction>

    </xsd:simpleType>

    <xsd:simpleType name="ResultaatCodeType">

    <xsd:restriction base="xsd:string">

    <xsd:length value="7"/>

    </xsd:restriction>

    </xsd:simpleType>

    <xsd:simpleType name="ResultaatMeldingType">

    <xsd:restriction base="xsd:string"/>

    </xsd:simpleType>

    <xsd:simpleType name="StoringsnummerType">

    <xsd:restriction base="xsd:string">

    <xsd:maxLength value="16"/>

    </xsd:restriction>

    </xsd:simpleType>

    <xsd:simpleType name="StraatType">

    <xsd:restriction base="xsd:string">

    <xsd:minLength value="1"/>

    <xsd:maxLength value="128"/>

    </xsd:restriction>

    </xsd:simpleType>

    <xsd:simpleType name="TelefoonType">

    <xsd:restriction base="xsd:string">

    <xsd:maxLength value="16"/>

    </xsd:restriction>

    </xsd:simpleType>

    <xsd:simpleType name="ThemaNaamType">

    <xsd:restriction base="xsd:string">

    <xsd:enumeration value="Datatransport"/>

    <xsd:enumeration value="Gas hoge druk"/>

    <xsd:enumeration value="Gas lage druk"/>

    <xsd:enumeration value="Buisleiding"/>

    <xsd:enumeration value="Landelijk HS net"/>

    <xsd:enumeration value="Hoogspanning"/>

    <xsd:enumeration value="Middenspanning"/>

    <xsd:enumeration value="Laagspanning"/>

    <xsd:enumeration value="(Petro)chemie"/>

    <xsd:enumeration value="Riool vrij verval"/>

    <xsd:enumeration value="Riool onder druk"/>

    <xsd:enumeration value="Warmte"/>

    <xsd:enumeration value="Water"/>

    <xsd:enumeration value="Wees"/>

    <xsd:enumeration value="Overig"/>

    </xsd:restriction>

    </xsd:simpleType>

    <xsd:simpleType name="WerkzaamheidType">

    <xsd:restriction base="xsd:string"/>

    </xsd:simpleType>

    <xsd:simpleType name="WoonplaatsType">

    <xsd:restriction base="xsd:string"/>

    </xsd:simpleType>

    <xsd:simpleType name="AantalPixelsType">

    <xsd:restriction base="xsd:integer">

    <xsd:minInclusive value="5"/>

    <xsd:maxInclusive value="12500"/>

    </xsd:restriction>

    </xsd:simpleType>

    <xsd:complexType name="AdresType">

    <xsd:sequence>

    <xsd:element name="Straat" type="ct:StraatType"/>

    <xsd:element name="Huisnummer"/>

    <xsd:element name="Huisnummertoevoeging" minOccurs="0"/>

    <xsd:element name="Postcode" type="ct:PostcodeType" minOccurs="0"/>

    <xsd:element name="Woonplaats" type="ct:WoonplaatsType"/>

    </xsd:sequence>

    </xsd:complexType>

    <xsd:complexType name="BijlagenType">

    <xsd:sequence>

    <xsd:element name="Bijlage" type="ct:PDFBestandType" maxOccurs="unbounded"/>

    </xsd:sequence>

    </xsd:complexType>

    <xsd:complexType name="BundelingsverzoekType">

    <xsd:sequence>

    <xsd:element name="Ordernummer" type="ct:OrdernummerType"/>

    <xsd:element name="DatumVerzoek" type="ct:DatumType"/>

    <xsd:element name="Leveringsvolgnummer" type="ct:LeveringsVolgnummerType"/>

    <xsd:element name="Gebiedsinformatie" type="ct:GebiedsinformatieType" maxOccurs="unbounded"/>

    </xsd:sequence>

    </xsd:complexType>

    <xsd:complexType name="ContactType">

    <xsd:sequence>

    <xsd:element name="Bedrijf" type="ct:BedrijfsnaamType"/>

    <xsd:element name="Contactpersoon" type="ct:ContactpersoonType"/>

    <xsd:element name="Adres" type="ct:AdresType"/>

    <xsd:element name="Telefoon" type="ct:TelefoonType"/>

    <xsd:element name="Email" type="ct:EmailType"/>

    <xsd:element name="Fax" type="ct:FaxType"/>

    </xsd:sequence>

    </xsd:complexType>

    <xsd:complexType name="ContactpersoonType">

    <xsd:sequence>

    <xsd:element name="Naam"/>

    <xsd:element name="Telefoon"/>

    <xsd:element name="Email"/>

    </xsd:sequence>

    </xsd:complexType>

    <xsd:complexType name="DetailkaartenType">

    <xsd:sequence>

    <xsd:element name="Detailkaart" type="ct:PDFBestandType" maxOccurs="unbounded"/>

    </xsd:sequence>

    </xsd:complexType>

    <xsd:complexType name="GebiedsinformatieType">

    <xsd:sequence>

    <xsd:element name="Metadata" type="ct:MetadataType"/>

    <xsd:element name="Themas" type="ct:ThemasType"/>

    <xsd:element name="Bijlagen" type="ct:BijlagenType" minOccurs="0"/>

    <xsd:element name="EigenTopo" type="ct:PDFBestandType" minOccurs="0"/>

    <xsd:element name="PlanTopo" type="ct:PDFBestandType" minOccurs="0"/>

    </xsd:sequence>

    </xsd:complexType>

    <xsd:complexType name="GebruikerType">

    <xsd:sequence>

    <xsd:element name="GebruikerCode" type="ct:GebruikerCodeType"/>

    <xsd:element name="GebruikerNaam" type="ct:NaamType"/>

    <xsd:element name="Telefoon" type="ct:TelefoonType"/>

    <xsd:element name="Email" type="ct:EmailType"/>

    <xsd:element name="Fax" type="ct:FaxType" minOccurs="0"/>

    </xsd:sequence>

    </xsd:complexType>

    <xsd:complexType name="GrondroerderType">

    <xsd:sequence>

    <xsd:element name="Klant" type="ct:KlantType"/>

    <xsd:element name="Gebruiker" type="ct:GebruikerType"/>

    </xsd:sequence>

    </xsd:complexType>

    <xsd:complexType name="HuisaansluitschetsenType">

    <xsd:sequence>

    <xsd:element name="Huisaansluitschets" type="ct:PDFBestandType" maxOccurs="unbounded"/>

    </xsd:sequence>

    </xsd:complexType>

    <xsd:complexType name="KlantType">

    <xsd:sequence>

    <xsd:element name="Relatienummer" type="ct:RelatienummerType"/>

    <xsd:element name="Bedrijfsnaam" type="ct:BedrijfsnaamType"/>

    <xsd:element name="Adres" type="ct:AdresType"/>

    </xsd:sequence>

    </xsd:complexType>

    <xsd:complexType name="MetadataType">

    <xsd:sequence>

    <xsd:element name="Ordernummer" type="ct:OrdernummerType"/>

    <xsd:element name="Datum" type="ct:DatumType"/>

    <xsd:element name="Netbeheerder" type="ct:NetbeheerderType"/>

    <xsd:element name="Contact" type="ct:ContactpersoonType"/>

    <xsd:element name="ToezichtThemas" type="ct:ToezichtThemasType"/>

    <xsd:element name="Storingsnummer" type="ct:StoringsnummerType" minOccurs="0"/>

    <xsd:element name="Stuklijst" type="ct:StuklijstType"/>

    </xsd:sequence>

    </xsd:complexType>

    <xsd:complexType name="OntvangstbevestigingType">

    <xsd:sequence>

    <xsd:element name="DatumOntvangst" type="ct:DatumOntvangstType"/>

    <xsd:element name="Ordernummer" type="ct:OrdernummerType"/>

    <xsd:element name="Referentie" type="ct:ReferentieType" minOccurs="0"/>

    <xsd:element name="Resultaat" type="ct:ResultaatType"/>

    </xsd:sequence>

    </xsd:complexType>

    <xsd:complexType name="OpdrachtgeverType">

    <xsd:sequence>

    <xsd:element name="Bedrijf" type="ct:BedrijfsnaamType"/>

    <xsd:element name="Contactpersoon" type="ct:NaamType"/>

    <xsd:element name="Adres" type="ct:AdresType"/>

    <xsd:element name="Telefoon" type="ct:TelefoonType"/>

    <xsd:element name="Email" type="ct:EmailType"/>

    <xsd:element name="Fax" type="ct:FaxType"/>

    </xsd:sequence>

    </xsd:complexType>

    <xsd:complexType name="ResultaatType">

    <xsd:sequence>

    <xsd:element name="Resultaatcode" type="ct:ResultaatCodeType"/>

    <xsd:element name="Resultaatmelding" type="ct:ResultaatMeldingType"/>

    </xsd:sequence>

    </xsd:complexType>

    <xsd:complexType name="StuklijstType">

    <xsd:sequence>

    <xsd:element name="Bestandsnaam" type="ct:BestandsnaamType" maxOccurs="unbounded"/>

    </xsd:sequence>

    </xsd:complexType>

    <xsd:complexType name="ThemaType">

    <xsd:sequence>

    <xsd:element name="Themanaam" type="ct:ThemaNaamType"/>

    <xsd:element name="Ligging" type="ct:PNGBestandType"/>

    <xsd:element name="Maatvoering" type="ct:PNGBestandType" minOccurs="0"/>

    <xsd:element name="Annotatie" type="ct:PNGBestandType" minOccurs="0"/>

    <xsd:element name="Detailkaarten" type="ct:DetailkaartenType" minOccurs="0"/>

    <xsd:element name="Huisaansluitschetsen" type="ct:HuisaansluitschetsenType" minOccurs="0"/>

    <xsd:element name="ThemaBijlagen" type="ct:ThemaBijlagenType" minOccurs="0"/>

    </xsd:sequence>

    </xsd:complexType>

    <xsd:complexType name="ThemasType">

    <xsd:sequence>

    <xsd:element name="Thema" maxOccurs="unbounded">

    <xsd:complexType>

    <xsd:complexContent>

    <xsd:extension base="ct:ThemaType"/>

    </xsd:complexContent>

    </xsd:complexType>

    </xsd:element>

    </xsd:sequence>

    </xsd:complexType>

    <xsd:complexType name="ThemaBijlagenType">

    <xsd:sequence>

    <xsd:element name="ThemaBijlage" type="ct:PDFBestandType" maxOccurs="unbounded"/>

    </xsd:sequence>

    </xsd:complexType>

    <xsd:complexType name="ToezichthoudersType">

    <xsd:sequence>

    <xsd:element name="Toezichthouder" type="ct:ContactpersoonType" minOccurs="0" maxOccurs="unbounded"/>

    </xsd:sequence>

    </xsd:complexType>

    <xsd:complexType name="ToezichtThemaType">

    <xsd:sequence>

    <xsd:element name="ThemaNaam" type="ct:ThemaType"/>

    <xsd:element name="Toezichthouder" type="ct:ContactpersoonType"/>

    <xsd:element name="EisVoorzoorgmaatregel" type="ct:EisVoorzorgmaatregelType"/>

    </xsd:sequence>

    </xsd:complexType>

    <xsd:complexType name="ToezichtThemasType">

    <xsd:sequence>

    <xsd:element name="ToezichtThema" type="ct:ToezichtThemaType" maxOccurs="unbounded"/>

    </xsd:sequence>

    </xsd:complexType>

    <xsd:complexType name="WerkzaamhedenType">

    <xsd:sequence>

    <xsd:element name="Werkzaamheid" type="ct:WerkzaamheidType" maxOccurs="128"/>

    </xsd:sequence>

    </xsd:complexType>

    </xsd:schema>

     

    Thanks very much!!!
    Thursday, February 21, 2008 8:53 AM

Answers

  • What XSD.EXE -c needs is the following:

     

    <xs:element name="someRequest" type="SomeType" />

    <xs:complexType name="SomeType">
        <xsTongue Tiedequence>
          <xs:element name="SomeDate" type="xsBig SmileateTime" />
          <xs:element name="SomeName" type="xsTongue Tiedtring" />
        </xsTongue Tiedequence>
    </xs:complexType>
    Thursday, February 21, 2008 9:05 AM

All replies

  • What XSD.EXE -c needs is the following:

     

    <xs:element name="someRequest" type="SomeType" />

    <xs:complexType name="SomeType">
        <xsTongue Tiedequence>
          <xs:element name="SomeDate" type="xsBig SmileateTime" />
          <xs:element name="SomeName" type="xsTongue Tiedtring" />
        </xsTongue Tiedequence>
    </xs:complexType>
    Thursday, February 21, 2008 9:05 AM
  • I found some complexType with the type missing but still the same error.

     

    Do you mean that type cannot be one of the simple types?

     

    How should the simpleTypes be written for the xsd.exe?

     

    Thanks

    Thursday, February 21, 2008 10:24 AM
  • Hi



    I think you have to specify a complex type which would be your class name which has your simple types..


    Examples..

    XSD
    http://samples.gotdotnet.com/quickstart/util/srcview.aspx?path=/quickstart/howto/samples/Xmlserialization/PurchaseOrderXsd.src

    Source

    http://samples.gotdotnet.com/quickstart/util/srcview.aspx?path=/quickstart/howto/samples/Xmlserialization/PurchaseOrder.src

    Monday, March 03, 2008 5:01 PM