The type attribute cannot be present with either simpleType or complexType

后端 未结 1 1450
故里飘歌
故里飘歌 2021-01-23 23:26

I have the below XSD & when I am trying to generate XML out of it I am getting the above error : Error!!! The type attribute cannot be present with either simple

相关标签:
1条回答
  • 2021-01-23 23:59

    If you define the type of your element inline you can't name it so remove the type="InvoiceData" attribute (and then the name="InvoiceData" attribute as well).

    If you want to use those attributes then you need to separate element and type definition e.g. <xsl:element name="InvoiceData" type="InvoiceData"/> and <xsl:complexType name="InvoiceData">...</xsl:complexType>.

    The complete schema would be either

    <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
      <xs:element name="InvoiceData">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="HeaderFields">
              <xs:complexType>
                <xs:sequence>
                  <xs:element name="CompanyId" type="xs:string" />
                  <xs:element name="ImageID" type="xs:string" />
                  <xs:element name="Incident" type="xs:string" />
                  <xs:element name="FacilityID" type="xs:string" />
                </xs:sequence>
              </xs:complexType>
            </xs:element>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    </xs:schema>
    

    or

    <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    
      <xs:element name="InvoiceData" type="InvoiceData"/>
    
      <xs:complexType name="InvoiceData">
        <xs:sequence>
          <xs:element name="HeaderFields" type="HeaderFields"/>
        </xs:sequence>
      </xs:complexType>
    
      <xs:complexType name="HeaderFields">
        <xs:sequence>
          <xs:element name="CompanyId" type="xs:string" />
          <xs:element name="ImageID" type="xs:string" />
          <xs:element name="Incident" type="xs:string" />
          <xs:element name="FacilityID" type="xs:string" />
        </xs:sequence>
      </xs:complexType>
    
    </xs:schema>
    
    0 讨论(0)
提交回复
热议问题