Cannot create c# classes from XSD file

327 views Asked by At

I have some XSD schema files which can be found here .Its the bottom zip file named CR-27-EFK-xsd. When I try to create classes for example for ef15.xsd file with Xsd2Code it gives me

Error: Type'http://www.icisnet.gr/emcs/v1.03/types:DateType' is not declared

which is the same error that I get if I put as Custom Tool MsDataSetGenerator and run the custom tool to the XSD.

If I try to run from command the xsd tool xsd ef15.xsd /c it gives me an error

Warning: Schema could not be validated. Class generation may fail or may produce incorrect results.

Error: Error generating classes for schema 'ef15'.

  • Λείπει ο τύπος δεδομένων (trasnlation from Greek Missing data Type) 'http://www.icisnet.gr/emcs/v1.03/tms:HeaderType'.

I found in many answers in stackoverflow and other sites that I have to include all files in the same directory and specify them in xsd command so I tried many combinations like that

xsd ef15.xsd tms.xsd types.xsd doc.xsd /c

xsd doc.xsd types.xsd tms.xsd tcl.xsd ef15.xsd /c

and many other combinations but I always get error

Error: Το 'xsd' είναι ένα πρόθημα που δεν έχει δηλωθεί. Γραμμή 313, θέση 8. (I don't know how this could be translated to English)

NOTE: All the files that are imported in the ef15.xsd as schema are n the same folder with the ef15.xsd. Also all files that are needed are in the ZIP file. Doc.xsd, types.xsd, tml.xsd, tcl.xsd

Can someone help me out? Is there something wrong with the xsd files or am I doing something wrong?

1

There are 1 answers

1
martijn On BEST ANSWER

There is something wrong with the xsd's. I've downloaded the zip and tried to open the ef15.xsd into Altova XMLspy and it fails on the types.xsd that gets imported.

The problem is in this part of the types.xsd

<!--==========================================================-->
    <!--===                 CarbonDioxideEmissionsType         ===-->
    <!--==========================================================-->
    <xs:simpleType name="CarbonDioxideEmissionsType">
        <xs:annotation>
            <xs:documentation>
                <doc:description value="Carbon Dioxide Emissions"/>
            </xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:token">
            <xs:maxLength value="3"/>
            <xsd:pattern value="[0-9]{1,3}|-"/>
        </xs:restriction>
    </xs:simpleType>

the <xsd:pattern value="[0-9]{1,3}|-"/> is unknown and should be changed to <xs:pattern value="[0-9]{1,3}|-"/>

After this change the EF15.xsd is valid in altova.