Engineering Full Stack Apps with Java and JavaScript
XSD (XML Schema Definition), a recommendation of the World Wide Web Consortium (W3C), specifies how to formally describe the elements in an Extensible Markup Language (XML) document.
XSD can be used by programmers to verify each piece of item content in a document. They can check if it adheres to the description of the element it is placed in.
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
jxb:version="2.0">
<xsd:element name="hello" type="helloType"/>
<xsd:complexType name="helloType">
<xsd:sequence>
<xsd:element name="greeting" type="xsd:string"/>
<xsd:element name="name" type="nameType"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="nameType">
<xsd:simpleContent>
<xsd:extension base="xsd:string">
<xsd:attribute name="title" type="titleType">
</xsd:attribute>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
<xsd:simpleType name="titleType">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="Mr"/>
<xsd:enumeration value="Mrs"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:schema>
Corresponding XML can be:
<hello>
<greeting>Hello</greeting>
<name title="Mr">Heartin</name>
</hello>
An XML Schema describes the structure of an XML document, similar to a DTD.
XSD is the newer and preferred way over a DTD as XSD itself is an XML and can be validated.
An XML document with correct syntax is called "Well Formed".
An XML document validated against an XML Schema is both "Well Formed" and "Valid".
XSD can contain data types
may contain simple types and complex types
Complex types describe the permitted content of an element, including its element and text children and its attributes.
Simple types (also called data types) constrain the textual values that may appear in an element or attribute.
XSD provides a set of 19 primitive data types
XSD allows new data types to be constructed from the primitives
Mainly by three mechanisms:
restriction (reducing the set of permitted values),
list (allowing a sequence of values), and
union (allowing a choice of values from several types).
Twenty-five derived types are defined within the specification itself, and further derived types can be defined by users in their own schemas.
Please go throgh the attached reference links to learn more about XML.