为什么XSD。EXE创建两个.XSD文件,以及如何使用它们?

时间:2022-06-08 14:54:52

I am using the following command to generate related xsd file from my input XML file -- response.xml, my confusion is (1) why there are two xsd file output (response.xsd and response_app1.xsd), I think there should be only one of them generated? (2) If I need to generate C# class file by using xsd /classes, which xsd file should I use?

我正在使用以下命令从我的输入XML文件—响应—生成相关的xsd文件。xml,我的困惑是(1)为什么有两个xsd文件输出(响应)。xsd和response_app1.xsd),我认为应该只生成其中的一个?(2)如果需要使用xsd /class生成c#类文件,应该使用哪个xsd文件?

My environment: VSTS 2008 + C# + .Net 3.5.

我的环境:VSTS 2008 + c# +。net 3.5。

D:\>xsd response.xml
Microsoft (R) Xml Schemas/DataTypes support utility
[Microsoft (R) .NET Framework, Version 2.0.50727.3038]
Copyright (C) Microsoft Corporation. All rights reserved.
Writing file 'D:\response.xsd'.

Here is my input XML file and ouput XSD files,

这是我的输入XML文件和ouput XSD文件,

http://www.mediafire.com/file/kzzoxw0zwgq/inputoutput.zip

http://www.mediafire.com/file/kzzoxw0zwgq/inputoutput.zip

EDIT 1:

编辑1:

when I execute xsd response.xsd to generate related C# class, there are error messages, and here are the detailed output,

当我执行xsd响应时。要生成相关的c#类,有错误消息,下面是详细的输出,

D:\>xsd response.xsd /classes
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: The 'http://www.mycorp.com/Order/2009/05/mex:Items' e
lement is not declared. Line 10, position 16.

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

Error: Error generating classes for schema 'response'.
  - The element 'http://www.mycorp.com/Order/2009/05/mex:Items' is missing.

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

thanks in advance, George

提前谢谢,乔治

4 个解决方案

#1


5  

George,

乔治,

To generate classes from these files, you must list both on the command line:

要从这些文件中生成类,您必须在命令行中列出这两个类:

D:\>xsd response.xsd response_app1.xsd /classes 

It has already been correctly said that the two .xsd files are because there were two XML namespaces in your original XML file. BTW, I'm guessing a little here because you did not post the XML file.

已经正确地说,这两个.xsd文件是因为原始XML文件中有两个XML名称空间。顺便说一句,我在这里猜测一下,因为您没有发布XML文件。

#2


2  

The reason why two files are getting generated is because your XML contains two XML namespaces; each generated XSD corresponds to a namespace. The one for the soap envelope namespace imports the mycorp namespace (which you can see from the xs:import element).

生成两个文件的原因是您的XML包含两个XML名称空间;每个生成的XSD对应于一个名称空间。soap信封命名空间的名称空间导入mycorp命名空间(可以从xs:import元素中看到)。

#3


1  

IIRC, you use both, one will probably reference the other.

IIRC,两者都用,一个可能会引用另一个。

#4


-2  

Yes, remove the namespaces from XML file and generate it, you will get single XSD file

是的,从XML文件中删除名称空间并生成它,您将获得单个XSD文件

#1


5  

George,

乔治,

To generate classes from these files, you must list both on the command line:

要从这些文件中生成类,您必须在命令行中列出这两个类:

D:\>xsd response.xsd response_app1.xsd /classes 

It has already been correctly said that the two .xsd files are because there were two XML namespaces in your original XML file. BTW, I'm guessing a little here because you did not post the XML file.

已经正确地说,这两个.xsd文件是因为原始XML文件中有两个XML名称空间。顺便说一句,我在这里猜测一下,因为您没有发布XML文件。

#2


2  

The reason why two files are getting generated is because your XML contains two XML namespaces; each generated XSD corresponds to a namespace. The one for the soap envelope namespace imports the mycorp namespace (which you can see from the xs:import element).

生成两个文件的原因是您的XML包含两个XML名称空间;每个生成的XSD对应于一个名称空间。soap信封命名空间的名称空间导入mycorp命名空间(可以从xs:import元素中看到)。

#3


1  

IIRC, you use both, one will probably reference the other.

IIRC,两者都用,一个可能会引用另一个。

#4


-2  

Yes, remove the namespaces from XML file and generate it, you will get single XSD file

是的,从XML文件中删除名称空间并生成它,您将获得单个XSD文件