Why is XSD.EXE creating two .XSD files and how to use them?

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

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:\response.xsd'. 

Here is my input XML file and Ouput XSD files,

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

EDIT 1:

when I execute xsd response.xsd to create a related C # class, error messages appear and here is 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 /?". 

thanks in advance George

+6
c # xml xsd
source share
4 answers

George,

To generate classes from these files, you must specify 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 related to the fact that there were two XML namespaces in the original XML file. By the way, I have a little guess because you did not publish the XML file.

+5
source share

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

+2
source share

IIRC, you use both, one probably refers to the other.

+1
source share

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

-2
source share

All Articles