Chapter 2. Our First Schema
Starting with a simple example (a limited number of elements and attributes and containing no namespaces), we will see how a first schema can be simply derived from the document structure, using a catalog of the elements in a document as we write a DTD for this document.
The Instance Document
The instance document, which we use in the first part of this book, is a simple library file describing a book, its author, and its characters:
<?xml version="1.0"?> <library> <book id="b0836217462" available="true"> <isbn> 0836217462 </isbn> <title lang="en"> Being a Dog Is a Full-Time Job </title> <author id="CMS"> <name> Charles M Schulz </name> <born> 1922-11-26 </born> <dead> 2000-02-12 </dead> </author> <character id="PP"> <name> Peppermint Patty </name> <born> 1966-08-22 </born> <qualification> bold, brash and tomboyish </qualification> </character> <character id="Snoopy"> <name> Snoopy </name> <born> 1950-10-04 </born> <qualification> extroverted beagle </qualification> </character> <character id="Schroeder"> <name> Schroeder </name> <born> 1951-05-30 </born> <qualification> brought classical music to the Peanuts strip </qualification> </character> <character id="Lucy"> <name> Lucy </name> <born> 1952-03-03 </born> <qualification> bossy, crabby and selfish </qualification> </character> </book> </library>
Our First Schema
We will see, in the course of this book, that there are many different styles for writing a schema, and there are even more approaches to deriving ...
Get XML Schema 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.