Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用xsd.exe生成c#文件,获取错误和警告_C#_Xsd_Xsd.exe - Fatal编程技术网

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

使用xsd.exe生成c#文件,获取错误和警告,c#,xsd,xsd.exe,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

这是我正在运行的命令:

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复制/粘贴的:

您链接的PDF文档中包含的XML模式使用
元素引用了其他几个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是通过导入和MySchema.xsd中的include元素引用的xsd文件。

我遇到了同样的问题,我就是这样解决的:

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

C:\Projects\Project1\Documents\xsds\structre>“C:\Program Files(x86)\Microsoft SDK\Windows\v7.0A\Bin\NETFX 4.0 Tools\xsd”structure.xsdRefXsd1.xsd RefXsd2.xsd RefXsd3.xsd/C/o:C:\Projects\Project1\Documents\ClassStructure

在文件夹c:\Projects\Project1\Documents\ClassStructure下生成了一个c-sharp文件,其中包含xsds中提到的实体


希望这有帮助

我在本地添加了所有文件,包括那些文件调用的文件。但还是有同样的错误。我很确定我的问题是错误:缺少数据类型“”。是否已将所有架构添加到同一文件夹中?我看到的
import
语句在不同的目录级别引用了这些额外的模式。您可能仍然存在由于路径问题而找不到引用的架构的问题。您可以将它们添加到命令行中,并保持“HintPath”不变。只需提及导入的每个模式(如果这些模式再次导入,请清洗并重复)。xsd.exe/c TopSchema.xsd ImportSchema1.xsd。。。ImportToImportSchema1.xsd对不起,“HintPath”和“Rish&repeat”是什么意思?我尝试使用其他工具,如svcutil和Xsd2Code,但每个工具都有错误,架构文件会弄乱吗?谢谢!在过去的几个小时里,我一直在为这件事发愁。我不知道您必须列出主xsd中正在导入/包含的所有xsd文件(以及所有导入/隐藏的文件)。即使我仔细列出了所有引用的.xsd文件,我仍然会收到此警告。不知道为什么