0

I've looked all over stackoverflow for an answer for this, but unfortunately all the ansers didn't work for me:

I have the following xml:

<STGDocument version="3" workitem-id="0" index="1">
       <ID type="String">ab78e02c-a472-45b9-99d0-57c19034a51b</ID>
....

And the XSD generated from a webpage :

<xs:element name="STGDocument">
<xs:complexType>
  <xs:sequence>
    <xs:element name="ID" type="xs:string">
      <xs:complexType>
        <xs:attribute name="type" type="xs:string"></xs:attribute>
      </xs:complexType>
    </xs:element>
.......

Somehow the <xs:element name "Id" ....> Tag throws an error "The type attribute cannot be present with either simpleType or complexType"

How can i fix this?

As mentioned before, I tried all the solutions on SOF but none of them worked for me...

Thnaks

Adrian Melzer
  • 159
  • 1
  • 1
  • 9

1 Answers1

1

The type of an element is declared EITHER using a type attribute (like type="xs:string") OR using a nested xs:simpleType or xs:complexType element. You can't have both, which is why it is complaining.

The actual type of your ID element is a "complex type with simple content", and should be declared as in this example: XSD : How to use both value and attribute

Michael Kay
  • 156,231
  • 11
  • 92
  • 164