我正在尝试转换 XSD一些 C# 类。我已经用很多其他文件完成了此操作,但我想知道为什么这个文件不起作用。
schema information在下载部分包含指向 the XSD file 的链接我已经下载到我的本地磁盘。然后从 ms 开发工具运行 XSD 命令。
这是来自命令提示符的转储:
C:\temp\XSD>xsd version-13-draft-ivi-xsd-scheme.xsd /classes /namespace:MyNamespace
Microsoft (R) Xml Schemas/DataTypes support utility
[Microsoft (R) .NET Framework, Version 4.6.1055.0]
Copyright (C) Microsoft Corporation. All rights reserved.
Schema validation warning: The 'http://www.w3.org/2000/09/xmldsig:Signature' element is not declared. Line 17, position 5.
Warning: Schema could not be validated. Class generation may fail or may produce incorrect results.
Error: Error generating classes for schema 'version-13-draft-ivi-xsd-scheme'.
- The element 'http://www.w3.org/2000/09/xmldsig#:Signature' is missing.
If you would like more help, please type "xsd /?".
XSD 验证器似乎无法下载签名命名空间。但我不确定到底发生了什么。谁能解释一下出了什么问题?
最佳答案
下载http://www.w3.org/TR/xmldsig-core/xmldsig-core-schema.xsd到您的本地目录,并将其作为另一个参数添加到您的命令中:
xsd version-13-draft-ivi-xsd-scheme.xsd xmldsig-core-schema.xsd /Classes
您要导入的 xsd 在第 7 行包含对该文件的引用:
<xs:import namespace="http://www.w3.org/2000/09/xmldsig#" schemaLocation="xmldsig-core-schema.xsd"/>
关于c# - 使用 xsd.exe 从 ereg 关联生成 c# 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45921523/