I am validating my XSD through https://www.freeformatter.com/xml-validator-xsd.html but it throws an error
The content of
sequence
must match(annotation?, (element | Group | Choice | Sequence | Any)*)
. A problem was found starting at:Attribute
I need to make NOT NULL for the reportType
. I used attribute (use="required"
) and tried to move the attribute out of sequence as well but it still throws an error. Any help will be appreciated.
Below is my XSD code.
<?xml version="1.0"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="missing">
<xs:complexType>
<xs:sequence>
<xs:element name="missingID" type="xs:string"/>
<xs:attribute name="reportType" use="required"/>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value= "1"/>
<xs:maxLength value= "255"/>
</xs:restriction>
</xs:simpleType>
<xs:element name="reportDescription">
<xs:simpleType >
<xs:restriction base="xs:string">
<xs:minLength value= "1"/>
<xs:maxLength value= "255"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="contact">
<xs:simpleType >
<xs:restriction base="xs:string">
<xs:minLength value= "1"/>
<xs:maxLength value= "255"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="reward">
<xs:simpleType >
<xs:restriction base="xs:string">
<xs:minLength value= "1"/>
<xs:maxLength value= "255"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="location">
<xs:simpleType >
<xs:restriction base="xs:string">
<xs:minLength value= "1"/>
<xs:maxLength value= "255"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="photo" type="xs:base64Binary"/>
<xs:element name="statusID" type="xs:string"/>
<xs:element name="userID" type="xs:string"/>
<xs:element name="created_date">
<xs:simpleType>
<xs:restriction base="xs:dateTime"/>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
(Added from a subsequent comment:)
This is the xml I'm working with my xsd.
<?xml version="1.0" encoding="UTF-8"?>
<missing>
<missingID> m1234 </missingID>
<reportType> Missing Report </reportType>
<reportDescription> A person was missing yesterday at Manhattan around 8 P.M. </reportDescription>
<contact> 1234567891 </contact>
<reward> Cash $10000 </reward>
<location> New York </location>
<photo> </photo>
<statusID> s1234 </statusID>
<userID> a1234 </userID>
<created_date> 2019-11-29T09:00:15 </created_date>
</missing>