gpt4 book ai didi

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

转载 作者:数据小太阳 更新时间:2023-10-29 01:51:15 26 4
gpt4 key购买 nike

我正在使用以下命令从我的输入 XML 文件 -- response.xml 生成相关的 xsd 文件,我的困惑是 (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 文件。

关于c# - 为什么 XSD.EXE 创建两个 .XSD 文件,以及如何使用它们?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1084071/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com