Associating Schemas with XML Documents

There are a number of elements described by the XML Schemas: Structures Recommendation that are designed to link XML Schemas to the XML instance documents with which they are to be used in conjunction. Those elements have actually been given their own namespace:

http://www.w3.org/2001/XMLSchema-instance

The XML Instance namespace is a very important one, even though it does not contain many elements. It is how you associate an XML Schema with a document.

Let's look at a very simple schema and an XML document. This will simply be a document for storing a person's name and telephone number. Our schema might look something like this:

 <?xml version="1.0" encoding="UTF-8" ?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> ...

Get Special Edition Using XML, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.