by Eric van der Vlist is published by O'Reilly & Associates (ISBN: 0596004214)

Patterns, and Only Patterns

In science, strong theories tend to be simple, yet have almost infinite potential for complexity in application. RELAX NG is, because of its simplicity, one of those theories that is easy to explain, easy to implement, and generic and flexible enough to meet the most stringent requirements.

I'll present the RELAX NG patterns throughout this book, but I'd like to make a brief introduction here. In RELAX NG, there are three basic patterns that match the three types of XML nodes:

These basic patterns can be combined into ordered or nonordered groups and used in choices defining alternatives among several patterns. The cardinality of a pattern (i.e., the number of times it can appear in an instance document) can also be controlled. Text nodes can be also be constrained as data, which can be limited to particular datatypes and possibly be split into list items. Lastly, a whole set of features supports the creation of reusable libraries of patterns. Similar to patterns, name classes define sets of elements and attributes that can be used to open a schema and control where elements and attributes with unknown names may be included in the instance documents.

Some of these features have been defined to facilitate the work of writing RELAX NG schemas and go beyond the basic (sometimes called "atomic") patterns. To avoid complicating the basic model with these convenience features, the RELAX NG specification describes a simplification algorithm. This algorithm is used internally by RELAX NG processors to transform a full schema into a simpler form with fewer and simpler patterns. This algorithm is presented in Chapter 15.


RELAX NG doesn't pay attention to XML processing instructions and comments.

This text is released under the Free Software Foundation GFDL.