I converted a lot of xsd to C# in the past, but today I'm facing a new error message, for me: "cannot generate classes because no top-level elements with complex type were found."
I have this problem on 2 files. I read a lot of posts about this, and they helped me to solve at least 1 of the 2 problems I have.
The file I fixed was:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:mg="urn:crif-messagegateway:2006-08-23" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:crif-messagegateway:2006-08-23" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="MGRequest" type="xs:string"/>
<xs:element name="MGResponse" type="xs:string"/>
</xs:schema>
and I edited it to:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:mg="urn:crif-messagegateway:2006-08-23" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:crif-messagegateway:2006-08-23" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="MGRequest">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string" />
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="MGResponse">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string" />
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:schema>
Now, I'm trying also to convert the following xsd file (quite similar to the previous fixed), but it xsd.exe throws the error "cannot generate classes because no top-level elements with complex type were found.". Which is the problem? What are the differences between the working file above?
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:mg="urn:crif-messagegateway:2006-08-23" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:crif-messagegateway:2006-08-23" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="MGRequest">
<xs:complexType>
<xs:sequence>
<xs:any namespace="##other"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="MGResponse">
<xs:complexType>
<xs:sequence>
<xs:any namespace="##other"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
I tried also with xsd2code, but what I get is just an empty class.