cfleming93
cfleming93

Reputation: 219

XML Schema not well-formed, what is my issue?

The error I'm getting when checking validity is:

Not valid.
Error - Line 8, 40: org.xml.sax.SAXParseException; lineNumber: 8; 
columnNumber: 40; s4s-elt-invalid-content.1: The content of '#AnonType_xmtma' 
is invalid.  Element 'element' is invalid, misplaced, or occurs too often.`

The piece of code it's referring to is:

<xs:element name="xmtma">
    <xs:complexType>
       <xs:element ref="contact" /> <!--LINE 8-->
    </xs:complexType>
</xs:element>
<xs:element name="contact">
    <xs:complexType>
        <xs:choice>
            <xs:element ref="personal" />
            <xs:element ref="company" />
        </xs:choice>
    </xs:complexType>
</xs:element>

Can you see what I'm doing wrong here?

Upvotes: 3

Views: 212

Answers (1)

Mathias Vonende
Mathias Vonende

Reputation: 1380

You can't have an xs:element-Element as a child to your xs:complexType-Element. Have a look at: W3-Schools for the Syntax of xs:complexType-Elements in XML-Schemata.

You could wrap your xs:element inside a xs:sequence for example.

<xs:element name="xmtma">
  <xs:complexType>
    <xs:sequence (... additional attributes ...)>
      <xs:element ref="contact" />
    </xs:sequence>
  </xs:complexType>
</xs:element>

Upvotes: 2

Related Questions