Classes cannot be generated because top level elements with complex type were not found

I am trying to create a class from an xsd file using the XSD.EXE tool. but for some reason I get this error.

Warning: classes cannot be created because top-level elements with a complex type.

I looked at the stack and saw that I could put the type on an element of a complex type, but I could not get it to work. here is the xsd file

    <?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
     targetNamespace="http://www.unece.org/cefact/namespaces/StandardBusinessDocumentHeader"
     xmlns="http://www.unece.org/cefact/namespaces/StandardBusinessDocumentHeader"
     elementFormDefault="qualified" attributeFormDefault="unqualified">

  <xs:complexType name="DocumentIdentification">
    <xs:sequence>
      <xs:element name="Standard" type="xs:string"/>
      <xs:element name="TypeVersion" type="xs:string"/>
      <xs:element name="InstanceIdentifier" type="xs:string"/>
      <xs:element name="Type" type="xs:string"/>
      <xs:element name="MultipleType" type="xs:boolean" minOccurs="0"/>
      <xs:element name="CreationDateAndTime" type="xs:dateTime"/>
    </xs:sequence>
  </xs:complexType>
</xs:schema>

Thanks!

+4
source share
1 answer

XSD ( ). , XML, XSD. , , xsd.exe, .

#, , .

. , - :

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://www.unece.org/cefact/namespaces/StandardBusinessDocumentHeader"
    xmlns="http://www.unece.org/cefact/namespaces/StandardBusinessDocumentHeader"
    elementFormDefault="qualified" attributeFormDefault="unqualified">

    <xs:complexType name="DocumentIdentification">
        <xs:sequence>
            <xs:element name="Standard" type="xs:string" />
            <xs:element name="TypeVersion" type="xs:string" />
            <xs:element name="InstanceIdentifier" type="xs:string" />
            <xs:element name="Type" type="xs:string" />
            <xs:element name="MultipleType" type="xs:boolean" minOccurs="0" />
            <xs:element name="CreationDateAndTime" type="xs:dateTime" />
        </xs:sequence>
    </xs:complexType>

    <xs:element name="DocumentIdentification" type="DocumentIdentification" />
</xs:schema>

, . typenames Type, DocumentIdentificationType.

xsd.exe.

+2

Source: https://habr.com/ru/post/1605920/


All Articles