无法从 XSD 文件创建 c# 类

Cannot create c# classes from XSD file

我有一些 XSD 可以找到的模式文件 here。它是名为 CR-27-EFK-xsd 的底部 zip 文件。当我尝试使用 Xsd2Code 为 ef15.xsd 文件创建 类 时,它给了我

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

这与我将自定义工具 MsDataSetGenerator 和 运行 自定义工具放入 XSD 时得到的错误相同。

如果我尝试 运行 从命令 xsd 工具 xsd ef15.xsd /c 它给我一个错误

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'.

我在 Whosebug 和其他网站的许多答案中发现我必须将所有文件包含在同一目录中并在 xsd 命令中指定它们所以我尝试了很多这样的组合

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

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

和许多其他组合,但我总是出错

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

注意:在 ef15.xsd 作为架构中导入的所有文件都与 ef15.xsd 在同一文件夹中。 此外,所有需要的文件都在 ZIP 文件中。 Doc.xsd、types.xsd、tml.xsd、tcl.xsd

有人可以帮帮我吗? xsd 文件有问题还是我做错了什么?

xsd 有问题。我已经下载了 zip 并尝试将 ef15.xsd 打开到 Altova XMLspy 中,但它在导入的 types.xsd 上失败了。

问题出在这部分 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>

<xsd:pattern value="[0-9]{1,3}|-"/> 未知,应更改为 <xs:pattern value="[0-9]{1,3}|-"/>

此更改后 EF15.xsd 在 altova 中有效。