WebReference.com - Part 1 of Chapter 1: Professional XML Schemas, from Wrox Press Ltd (2/5)
[previous] [next] |
Professional XML Schemas
The W3C XML Schema Recommendation
The W3C Recommendation for XML Schema comes in three parts:
XML Schema Part 0: Primer The first part is a descriptive, example-based document, which introduces some of the key features of XML Schema by way of sample schemas. It is easy to read, and is a good start for getting to grips with XML Schemas and understanding what they are capable of. It can be read at https://www.w3.org/TR/xmlschema-0/.
XML Schema Part 1: Structures The next part describes how to constrain the structure of XML documents  where the information items (elements, attributes, notations, and so on) can appear in the schema. Once we have declared an element or an attribute, we can then define allowable content or values for each. It also defines the rules governing schema-validation of documents. It can be read at https://www.w3.org/TR/xmlschema-1/.
XML Schema Part 2: Datatypes The third part defines a set of built-in datatypes, which can be associated with element content and attribute values; further restricting allowable content of conforming documents and facilitating the management of dates, numbers, and other special forms of information by software processing of the XML documents. It also describes ways in which we can control derivation of new types from those that we have defined. It can be read at https://www.w3.org/TR/xmlschema-2/.
As we shall see throughout the course of this chapter and the rest of the book, there are a number of advantages to using XML Schemas over DTDs. In particular:
As they are written in XML syntax (which DTDs were not), we do not have a new syntax to learn before we can start learning the rules of writing a schema. It also means that we can use any of the tools we would use to work with XML documents (from authoring tools, through SAX and DOM, to XSLT), to work with XML Schemas.
The support for datatypes used in most common programming languages, and the ability to create our own datatypes, means that we can constrain the document content to the appropriate type required by applications, and / or replicate the properties of fields found in databases.
It provides a powerful class and type system allowing an explicit way of extending and re-using markup constructs, such as content models, which is far more powerful than the use of parameter entities in DTDs, and a way of describing classes of elements to facilitate inheritance.
The support for XML Namespaces allows us to validate documents that use markup from multiple namespaces and means that we can re-use constructs from schemas already defined in a different namespace.
They are more powerful than DTDs at constraining mixed content models.
[previous] [next] |
Created: October 18, 2001
Revised: October 18, 2001
URL: https://webreference.com/authoring/languages/xml/schemas/chap1/1/2.html