2009-07-05 69 views
6

我使用下面的命令來從我的輸入XML文件相關的XSD文件 - response.xml,我的困惑是:(1)爲什麼有兩個XSD文件輸出(response.xsd和response_app1.xsd),我認爲有應該只是其中的一個產生? (2)如果我需要通過使用xsd/classes生成C#類文件,我應該使用哪個xsd文件?爲什麼XSD.EXE創建兩個.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 /?". 

先前感謝, 喬治

回答

1

IIRC,你使用兩個,一個可能會引用另一個。

+0

@leppie 1.當我執行XSD response.xsd生成相關的C#類,也有錯誤消息。我已經發布在我原來的帖子編輯1部分。任何想法有什麼不對? 2.「一個人可能會引用另一個人」 - 你如何證明這一點? – George2 2009-07-05 14:06:53

2

爲什麼兩個文件如何產生是因爲你的XML包含兩個XML命名空間的原因;每個生成的XSD都對應一個名稱空間。肥皂包名稱空間用於導入mycorp名稱空間(您可以從xs:import元素中看到)。

+0

我的困惑是,爲什麼一個XSD文件只能包含一個名稱空間? – George2 2009-07-05 16:52:43

+0

另一個困惑是有4個命名空間,它們是xmlns:soapenv =「http://schemas.xmlsoap.org/soap/envelope/」xmlns:xsd =「http://www.w3.org/2001/XMLSchema」 xmlns:xsi =「http://www.w3.org/2001/XMLSchema-instance」和mycorp命名空間,爲什麼你說只有2個命名空間? – George2 2009-07-05 16:56:09

5

喬治,

爲了從這些文件中的類,則必須在命令行上同時列出:

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

它已經被正確地說,這兩個xsd文件是因爲原始XML文件中有兩個XML名稱空間。順便說一句,我猜這裏有一點,因爲你沒有發佈XML文件。

-2

是的,從XML文件中刪除的命名空間,並生成它,你會得到一個XSD文件

相關問題