問題描述
我正在使用以下命令從我的輸入 XML 文件生成相關的 xsd 文件——response.xml,我的困惑是(1)為什么有兩個 xsd 文件輸出(response.xsd 和 response_app1.xsd),我想應該只生成其中一個?(2) 如果我需要使用 xsd/classes 生成 C# 類文件,我應該使用哪個 xsd 文件?
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?
我的環境:VSTS 2008 + C# + .Net 3.5.
My environment: 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:
esponse.xsd'.
這是我的輸入 XML 文件和輸出 XSD 文件,
Here is my input XML file and ouput XSD files,
http://www.mediafire.com/file/kzzoxw0zwgq/inputoutput.zip
編輯 1:
當我執行xsd response.xsd生成相關C#類時,出現錯誤信息,這里是詳細輸出,
when I execute xsd response.xsd to generate related C# class, there are error messages, and here are the detailed output,
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 /?".
提前致謝,喬治
推薦答案
喬治,
要從這些文件中生成類,您必須在命令行中列出兩者:
To generate classes from these files, you must list both on the command line:
D:>xsd response.xsd response_app1.xsd /classes
<小時>
已經正確地說這兩個 .xsd 文件是因為您的原始 XML 文件中有兩個 XML 命名空間.順便說一句,我在這里猜測了一下,因為您沒有發布 XML 文件.
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.EXE 會創建兩個 .XSD 文件,以及如何使用它們?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!