XML schema describe the permitted XML sequences and constructs that are allowed in an XML document that conforms to the schema. Thus, they provide a stronger concept of "correctness" than mere syntactic validity.One particularly important use of schema is for defining the expected and allowed form of XML documents used for exchanging a particular type of information between two enterprises. Thus, for example, a trade association for a business sector, such as the automotive parts industry, the retail electronics industry, the airline reservation industry, might develop with its members the specification for data that can be exchanged among their respective computer systems.
The W3School's XML Schema Tutorial is a good introduction to the subject.
The example below is a schema for describing a system of tags sufficient for the AB3 problem concerning a simple addressbook whose interface is developed using XSL and XSLT from XML data.
Schema
<?xml version="1.0" encoding="UTF-8"?> - <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:element name="view" > <xsd:complexType> <xsd:sequence> <xsd:element maxOccurs="unbounded" minOccurs="1" ref="heading"/> <xsd:element maxOccurs="unbounded" minOccurs="0" ref="content"/> <xsd:element maxOccurs="unbounded" minOccurs="0" ref="message"/> </xsd:sequence> <xsd:attribute name="type" type="xsd:string" use="optional"/> </xsd:complexType> </xsd:element> <xsd:element name="heading" type="xsd:string"/> <xsd:element name="message" type="xsd:string"/> <xsd:element name="content"> <xsd:complexType> <xsd:sequence> <xsd:element maxOccurs="unbounded" minOccurs="0" ref="state"/> <xsd:element maxOccurs="unbounded" minOccurs="0" ref="entry"/> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd:element name="state"> <xsd:complexType> <xsd:sequence> <xsd:element maxOccurs="unbounded" minOccurs="0" ref="item"/> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd:element name="entry"> <xsd:complexType> <xsd:sequence> <xsd:element maxOccurs="unbounded" minOccurs="0" ref="item"/> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd:element name="item"> <xsd:complexType> <xsd:sequence> <xsd:element maxOccurs="1" minOccurs="0" ref="label"/> <xsd:element maxOccurs="1" minOccurs="0" ref="name"/> <xsd:element maxOccurs="1" minOccurs="0" ref="value"/> </xsd:sequence> <xsd:attribute name="type" type="xsd:string" use="optional"/> </xsd:complexType> </xsd:element> <xsd:element name="label" type="xsd:string"/> <xsd:element name="name" type="xsd:string"/> <xsd:element name="value" type="xsd:string"/> </xsd:schema>
Attaching to XML Document
<
view type="login"
xsi:noNamespaceSchemaLocation="../xsl/ABSchema.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">