c# - 使用 xsd.exe 生成 c# 文件,出现错误和警告

标签 c# xsd xsd.exe

这是我正在运行的命令:

xsd.exe -c -l:c# D:\Documents\DEV\SARPilot\Docs\schemas\06-141r2\06-141r2.xsd

这些是我遇到的错误:

Microsoft (R) Xml Schemas/DataTypes support utility
[Microsoft (R) .NET Framework, Version 2.0.50727.3038]
Copyright (C) Microsoft Corporation. All rights reserved.
Schema validation warning: Undefined complexType 'http://www.opengis.net/sps/0:ParameterDescriptorType' is used as a base for comp
lex type extension. Line 617, position 2.
Schema validation warning: Undefined complexType 'http://www.opengis.net/ows:GetCapabilitiesType' is used as a base for complex ty
pe extension. Line 23, position 2.
Schema validation warning: Undefined complexType 'http://www.opengis.net/ows:CapabilitiesBaseType' is used as a base for complex t
ype extension. Line 35, position 2.
Schema validation warning: The 'http://www.opengis.net/gml:Point' element is not declared. Line 869, position 2.
Schema validation warning: The 'http://www.opengis.net/gml:Polygon' element is not declared. Line 870, position 2.
Schema validation warning: The 'http://www.opengis.net/gml:Rectangle' element is not declared. Line 871, position 2.
Schema validation warning: The 'http://www.opengis.net/sps/0:Parameter' element is not declared. Line 381, position 2.
Schema validation warning: The 'http://www.opengis.net/sps/0:ID' element is not declared. Line 451, position 2.

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

Error: Error generating classes for schema 'D:\Documents\DEV\SARPilot\Docs\schemas\06-141r2\06-141r2'.
  - The datatype 'http://www.opengis.net/ows:GetCapabilitiesType' is missing.

If you would like more help, please type "xsd /?".

C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin>

XSD 文件是从以下文档的附录 A 中复制/粘贴的: http://services.eoportal.org/portal/documents/06-141r2_Ordering_Services_for_Earth_Observation_Products_0.9.2.pdf

最佳答案

您链接的 PDF 文档中包含的 XML 模式引用了其他几个使用 <import> 的 XSD 文件。元素。您将需要下载这些额外的架构文件并确保 <import> 中的路径引用元素指向您本地计算机上的正确位置。

如果您仍然遇到错误,那是因为 xsd.exe 无法跟进外部引用。要解决此问题,请直接在命令行中指定所有必需的 XSD 文件,如下所示:

xsd.exe /c MySchema.xsd Import01.xsd Import02.xsd Include01.xsd Include02.xsd

其中 Import01.xsd、Import02.xsd、Include01.xsd 和 Include02.xsd 是通过导入引用的 XSD 文件,并包含 MySchema.xsd 中的元素。

关于c# - 使用 xsd.exe 生成 c# 文件,出现错误和警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4491619/

相关文章:

c# - CultureInfo.CurrentCulture.NumberFormat.CurrencySymbol 的等效文本

java - 为什么使用 Schema 验证 XML 时未验证数据类型?

xml - 验证属性中的空字符串

.net - 我在 Visual Studio 2008 中找不到 xsd.exe?

xml - 如何使用 XML 模式将多个 Excel 行导出到 XML 文件?

c# - 你如何让Word表格中的文本垂直对齐?

c# - 如何防止从 asp.net linkbutton 回发

c# - 将 Microsoft Office Communicator 2007 集成到 ASP.NET 页面中

SOAP 响应模式验证

xml - 无法生成临时类(结果=1)。错误 CS0030 : Cannot convert type