Csharp/C#教程:使用xsd.exe生成c#文件,获取错误和警告分享


使用xsd.exe生成c#文件,获取错误和警告

这是我正在运行的命令:

xsd.exe -c -l:c# D:DocumentsDEVSARPilotDocsschemas6-141r26-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 'https://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 'https://www.opengis.net/ows:GetCapabilitiesType' is used as a base for complex ty pe extension. Line 23, position 2. Schema validation warning: Undefined complexType 'https://www.opengis.net/ows:CapabilitiesBaseType' is used as a base for complex t ype extension. Line 35, position 2. Schema validation warning: The 'https://www.opengis.net/gml:Point' element is not declared. Line 869, position 2. Schema validation warning: The 'https://www.opengis.net/gml:Polygon' element is not declared. Line 870, position 2. Schema validation warning: The 'https://www.opengis.net/gml:Rectangle' element is not declared. Line 871, position 2. Schema validation warning: The 'https://www.opengis.net/sps/0:Parameter' element is not declared. Line 381, position 2. Schema validation warning: The 'https://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:DocumentsDEVSARPilotDocsschemas6-141r26-141r2'. - The datatype 'https://www.opengis.net/ows:GetCapabilitiesType' is missing. If you would like more help, please type "xsd /?". C:Program Files (x86)Microsoft SDKsWindowsv7.0ABin> 

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

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

如果您仍然遇到错误,那是因为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中的元素。

我有同样的问题,这就是我解决它的方式:

1)将用于代码生成的xsd中引用的所有xsd文件复制到相同的位置,即“C: Projects Project1 Documents xsds strucutre”。 2)执行xsd.exe时提到所有引用的xsd文件:

C: Projects Project1 Documents xsds strucutre>“C: Program Files(x86) Microsoft SDKs Windows v7.0A Bin NETFX 4.0 Tools xsd”structure.xsd RefXsd1.xsd RefXsd2.xsd RefXsd3 .xsd / c / o:C: Projects Project1 Documents ClassStructure

在文件夹C: Projects Project1 Documents ClassStructure下生成包含xsds中提到的实体的c-sharp文件。

希望这可以帮助!

上述就是C#学习教程:使用xsd.exe生成c#文件,获取错误和警告分享的全部内容,如果对大家有所用处且需要了解更多关于C#学习教程,希望大家多多关注—计算机技术网(www.ctvol.com)!

本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

ctvol管理联系方式QQ:251552304

本文章地址:https://www.ctvol.com/cdevelopment/1020082.html

(0)
上一篇 2022年1月4日
下一篇 2022年1月4日

精彩推荐