Preface

As developers create new XML vocabularies, they often need to describe those vocabularies to share, define, and apply them. This book will guide you through W3C XML Schema, a set of Recommendations from the World Wide Web Consortium (W3C). These specifications define a language that you can use to express formal descriptions of XML documents using a generally object-oriented approach. Schemas can be used for documentation, validation, or processing automation. W3C XML Schema is a key component of Web Services specifications such as SOAP and WSDL, and is widely used to describe XML vocabularies precisely.

With this power comes complexity. The Recommendations are long, complex, and generally difficult to read. The Primer helps, of course, but there are many details and style approaches to consider in building schemas. This book attempts to provide an objective, and sometimes critical, view of the tools W3C XML Schema provides, helping you to discover the possibilities of schemas while avoiding potential minefields.

Who Should Read This Book?

Read this book if you want to:

  • Create W3C XML Schema schemas using a text editor, XML editor, or a W3C XML Schema IDE or editor.

  • Understand and modify existing W3C XML Schema schemas.

You should already have a basic understanding of XML document structures and how to work with them.

Who Should Not Read This Book?

If you are just using an XML application using a W3C XML Schema schema, you probably do not need to deal with the subtleties of the Recommendation.

About the Examples

All the examples in this book have been tested with the XSV and Xerces-J implementations of W3C XML Schema running Linux (the Debian “sid” distribution). I have chosen these tools for their high level of conformance to the Recommendation (the best ones according to the tests I have performed); the vast majority runs without error on these implementations—however, the Recommendation is sometimes fuzzy and difficult to understand, and there are some examples that give different results with different implementations. These conform to my own understanding of the Recommendation as discussed on the xmlschema-dev mailing list (the archives are available at http://lists.w3.org/Archives/Public/xmlschema-dev).

Organization of This Book

Chapter 1

This chapter examines why we would want to bring a new XML Schema language onto the XML scene and what basic benefits W3C XML Schema offers.

Chapter 2

This chapter presents a first complete schema, introducing the basic features of the language in a very “flat” style.

Chapter 3

With W3C XML Schema, style matters. This chapter gives a second example of a complete schema, describing the same class of documents, and written in a completely different style called “Russian doll design.”

Chapter 4

W3C XML Schema also provides datatyping. In this chapter, we explore how these types can be bound to the content of our document.

Chapter 5

This chapter guides you through the process of defining your own simple types.

Chapter 6

This chapter explores how to constrain new datatypes using regular expressions.

Chapter 7

Now that we know all about simple types, this chapter explores the different complex types that can be used to define structures within an XML document.

Chapter 8

This chapter shows how to organize schema tools into reusable building blocks.

Chapter 9

In addition to content (simple types) and structure (complex types), W3C XML Schema can constrain the identifiers and references within a document. We explore this feature in this chapter.

Chapter 10

Support for XML namespaces is one of the top requirements of W3C XML Schema. This chapter explains how this requirement has been implemented and its implications.

Chapter 11

This chapter shows how schema information may be embedded in the XML instance documents.

Chapter 12

This chapter explains how more building blocks may be defined, by playing with namespaces and justifying the object-oriented qualification given to W3C XML Schema.

Chapter 13

This chapter gives some hints to write extensible and open schemas.

Chapter 14

This chapter shows how schemas can be documented and made more readable, either by humans or programs.

Chapter 15

This is a quick reference guide to the elements used by W3C XML Schema.

Chapter 16

This is a quick reference guide to the W3C XML Schema predefined types.

Appendix A

W3C XML Schema is not the only language of its kind. Here we provide a short history of this not-so-new family and see some of its competitors.

Appendix B

If you want to look ahead at what’s to come from the W3C, you may be interested in this list of promising developments yet to be done in relation with W3C XML Schema.

Glossary

This provides short definitions for the main concepts and acronyms manipulated in the book.

Conventions Used in This Book

Constant Width

Used for attributes, datatypes, types, elements, code examples, and fragments.

Constant Width Bold

Used to highlight a section of code being discussed in the text.

Constant Width Italic

Used for replaceable elements in code examples.

Tip

This icon designates a note, which is an important aside to the nearby text.

Warning

This icon designates a warning relating to the nearby text.

How to Contact Us

Please address comments and questions concerning this book to the publisher:

O’Reilly & Associates, Inc.
1005 Gravenstein Highway North
Sebastopol, CA 95472
(800) 998-9938 (in the United States or Canada)
(707) 829-0515 (international or local)
(707) 829-0104 (fax)

We have a web page for this book, where we list errata, examples, or any additional information. You can access this page at:

http://www.oreilly.com/catalog/xmlschema

To comment or ask technical questions about this book, send email to:

For more information about our books, conferences, Resource Centers, and the O’Reilly Network, see our web site at:

http://www.oreilly.com

Acknowledgments

I would like to thank the contributors of xmlhack for their encouragements, and more specifically Simon St.Laurent, whose role has been aggravated by the fact that he has also been my editor for this book and has shown a remarkable level of helpfulness and patience. I’d also like to thank Edd Dumbill, who helped me set up Debian on the laptop on which this book was written.

I have been lucky enough to work with Jeni Tennison as a technical reviewer. Jeni’s deep and thorough knowledge has been invaluable to my confidence in the deciphering of the Recommendation. Her friendly, yet accurate, reviews were my safety net while I was writing this book.

I am also very grateful to all the people who have answered my many nasty questions on the xmlschema-dev mailing list, especially Henry S. Thompson, Noah Mendelsohn, Ashok Malhotra, Priscilla Walmsley, and Jeni Tennison (yes, Jeni is helping people on this list too!).

Finally, I would like to thank my wife and children for their patience during the whole year I have spent writing this book. Hopefully, now that this work is over, they can retrieve their husband and father!

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.