XSD Definition for Enumerated Value

You can define an enumeration within the context of a simpleType. <xs:simpleType name=”color” final=”restriction” > <xs:restriction base=”xs:string”> <xs:enumeration value=”green” /> <xs:enumeration value=”red” /> <xs:enumeration value=”blue” /> </xs:restriction> </xs:simpleType> <xs:element name=”SomeElement”> <xs:complexType> <xs:sequence> <xs:element name=”Color” type=”color” /> </xs:sequence> </xs:complexType> </xs:element>

Recursion in an XML schema?

if you need a recursive type declaration, here is an example that might help: <xs:schema id=”XMLSchema1″ targetNamespace=”http://tempuri.org/XMLSchema1.xsd” elementFormDefault=”qualified” xmlns=”http://tempuri.org/XMLSchema1.xsd” xmlns:mstns=”http://tempuri.org/XMLSchema1.xsd” xmlns:xs=”http://www.w3.org/2001/XMLSchema” > <xs:element name=”node” type=”nodeType”></xs:element> <xs:complexType name=”nodeType”> <xs:sequence minOccurs=”0″ maxOccurs=”unbounded”> <xs:element name=”node” type=”nodeType”></xs:element> </xs:sequence> </xs:complexType> </xs:schema> As you can see, this defines a recursive schema with only one node named “node” which can be as … Read more

cvc-elt.1: Cannot find the declaration of element ‘MyElement’

Your schema is for its target namespace http://www.example.org/Test so it defines an element with name MyElement in that target namespace http://www.example.org/Test. Your instance document however has an element with name MyElement in no namespace. That is why the validating parser tells you it can’t find a declaration for that element, you haven’t provided a schema … Read more

what is the use of xsi:schemaLocation?

The Java XML parser that spring uses will read the schemaLocation values and try to load them from the internet, in order to validate the XML file. Spring, in turn, intercepts those load requests and serves up versions from inside its own JAR files. If you omit the schemaLocation, then the XML parser won’t know … Read more