I have run the following XSD through a few online XSD validators but none of them tell me what is wrong with my XSD. It just says "XSD Not Valid". Any help identifying the issue or point me to a site that might help me to identify the issue. This is only my 2nd XSD so I am not surprised that it is not correct in some way.
<xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
<xsd:element name='DemandData'>
<xsd:complexType>
<xsd:sequence>
<xsd:element name='RateInformation' minOccurs='1' maxOccurs='5000'>
<xsd:complexType>
<xsd:all>
<xsd:element name='RateID' minOccurs='1' nillable='false' maxOccurs='1'>
<xsd:simpleType>
<xsd:restriction base='xsd:string'>
<xsd:minLength value='19'/>
<xsd:maxLength value='19'/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name='RateName' minOccurs='1' nillable='false' maxOccurs='1' />
<xsd:element name='RatePlan_Url' minOccurs='0' nillable='true' maxOccurs='1' />
<xsd:element name='RateType' minOccurs='1' nillable='true' maxOccurs='1'>
<xsd:simpleType>
<xsd:restriction base='xsd:string'>
<xsd:enumeration value='R-D' />
<xsd:enumeration value='C-D' />
<xsd:enumeration value='V-D' />
<xsd:enumeration value='CPP' />
<xsd:enumeration value='VPP' />
<xsd:enumeration value='RTP' />
<xsd:enumeration value='DSR' />
<xsd:enumeration value='TOU' />
<xsd:enumeration value='T-D' />
<xsd:enumeration value='GHG' />
</xsd:restriction>
</xsd:simpleType>
</xsd:element><xsd:element name='Sector' minOccurs='0' nillable='true' maxOccurs='1'>
<xsd:simpleType>
<xsd:restriction base='xsd:string'>
<xsd:enumeration value='CEV' />
<xsd:enumeration value='Ind' />
<xsd:enumeration value='Res' />
<xsd:enumeration value='Agr' />
<xsd:enumeration value='All' />
<xsd:enumeration value='REV' />
<xsd:enumeration value='Com' />
<xsd:enumeration value='CIA' />
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name='API_Url' minOccurs='0' nillable='true' maxOccurs='1' />
<xsd:element name='EndUse' minOccurs='0' nillable='true' maxOccurs='1' />
<xsd:simpleType>
<xsd:restriction base='xsd:string'>
<xsd:enumeration value='All' />
<xsd:enumeration value='EV' />
<xsd:enumeration value='Other' />
<xsd:enumeration value='Solar' />
<xsd:enumeration value='Battery' />
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name='PriceInformation'>
<xsd:complexType>
<xsd:sequence>
<xsd:element name='PriceData'>
<xsd:complexType>
<xsd:all>
<xsd:element name='DateStart' minOccurs='1' nillable='false' maxOccurs='1' />
<xsd:element name='DateEnd' minOccurs='1' nillable='false' maxOccurs='1' />
<xsd:element name='DayStart' minOccurs='1' nillable='false' maxOccurs='1' />
<xsd:element name='DayEnd' minOccurs='1' nillable='false' maxOccurs='1' />
<xsd:element name='Price' minOccurs='1' nillable='false' maxOccurs='1' />
<xsd:element name='PriceName' minOccurs='1' nillable='false' maxOccurs='1' />
<xsd:element name='TimeStart' minOccurs='1' nillable='false' maxOccurs='1' />
<xsd:element name='TimeEnd' minOccurs='1' nillable='false' maxOccurs='1' />
<xsd:element name='Unit' minOccurs='1' nillable='false' maxOccurs='1' />
</xsd:all>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:all>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
Here is a link to one of the validators I was getting the XSD syntax error with: https://extendsclass.com/xml-schema-validator.html
Most XSD processors would have at least detected that the closing xsd:element
tag just before PriceInformation
,
<xsd:element name='EndUse' minOccurs='0' nillable='true' maxOccurs='1' />
<xsd:simpleType>
<xsd:restriction base='xsd:string'>
<xsd:enumeration value='All' />
<xsd:enumeration value='EV' />
<xsd:enumeration value='Other' />
<xsd:enumeration value='Solar' />
<xsd:enumeration value='Battery' />
</xsd:restriction>
</xsd:simpleType>
</xsd:element> <!-- Parsing realizes something is wrong here -->
<xsd:element name='PriceInformation'>
lacked a matching start tag – this is just basic well-formedness checking at the XML level.
The issue is that what was intended to be the matching start tag for that xsd:element
close tag was mistakenly self-closed:
<xsd:element name='EndUse' minOccurs='0' nillable='true' maxOccurs='1' />
^
remove that /
character, and the XSD will then be well-formed.