XML Schema
|
XML Schema, published as a W3C Recommendation in May 2001, is one of several XML schema languages. It was the first separate schema language for XML to achieve Recommendation status by the W3C.
Since other XML schema languages such as RELAX NG now exist, it is important to cite this language as either XML Schema or W3C XML Schema, always with the word Schema capitalized. An XML Schema instance is an XML Schema Definition (XSD) and typically has the filename extension ".xsd". The language itself is sometimes informally referenced as XSD, even though WXS (W3C XML Schema) is the more appropriate initialism.
In its appendix of references, XML Schema acknowledges the influence of DTD and other early XML schema efforts such as DDML, SOX, XML-Data, and XDR. It appears to have picked pieces from each of these proposals, but is also a compromise between them. Of those languages, two are still actively used and developed: XDR and SOX. Their sponsors, Microsoft and Commerce One, respectively, have both announced that they would support XML Schema for their new developments, so W3C XML Schema should become the only surviving member of this family.
After XML Schema-based validation, it is possible to express an XML document's structure and content in terms of the data model that was implicit during validation. The XML Schema data model includes:
- the vocabulary (Element/Attribute names)
- the content model (Relationships/Structure)
- and data types.
This collection of information is called the Post-Schema Validation Infoset (PSVI). This gives a valid XML document its "Type".
Example
An example of a very simple Schema to describe a country is given below.
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="country"> <xs:complexType> <xs:sequence> <xs:element name="name" type="xs:string"/> <xs:element name="population" type="xs:decimal"/> </xs:sequence> </xs:complexType> </xs:element> </xs:schema>
An example of an XML document that conforms to this schema is given below.
<country xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="country.xsd"> <name>France</name> <population>59.7</population> </country>
External links
- Zvon XML Schema Reference (http://www.zvon.org/xxl/xmlSchema2001Reference/Output/index.html)
- World Wide Web Consortium XML Schema (http://www.w3.org/XML/Schema)
- XSD tutorial (http://xmlzoo.net/xsd/) from XMLzoo
- http://www.xml.com/pub/a/2001/12/12/schemacompare.html
- XMLPatterns.com - Design patterns for developing XML Schema documents (http://www.xmlpatterns.com)
- W3Schools XML Schema Tutorial (http://www.w3schools.com/schema/default.asp)
- XML Schema Development Tutorial (http://www.stylusstudio.com/xml_schema_tutorial.html) from Stylus Studio - NB this is more of a tutorial in their own software than in the principles of XML Schema
de:XML Schema eo:XML-skemo fr:XML Schema ja:XMLスキーマ nl:XML Schema Definitietaal no:XML Schema pl:XML Schema