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

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

我的环境: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'. 

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

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

编辑1:

当我执行xsd response.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 /?". 

乔治,提前谢谢

乔治,

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

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

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

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

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

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