RELAX NG

Introduction

RELAX NG is almost as powerfull as XML Schema, but is much simpler to write. Because it was created after the DTD and XML Schema languages, its authors were able to take advantage of the previous work, and build a powerfull, simple language. Unfortuniatly, because it came into existance later, many tools are built for DTD and XML Schema languages, but not as many for RELAX NG.

There are two versions of the RELAX NG language. They are exactly equivilant, but are written with different syntax. One syntax is XML, the other is a compact syntax which is not XML. We will begin working with the compact syntax.

Compact syntax

The compact syntax is built using patterns. We will look at four basic patterns:

start
start name - The keyword start is followed by the name of the root element for a target document. If the RELAX NG document is simple, it may be obvious what is the root element, in which case the start pattern is optional.
element
element name { pattern } - The keyword element is followed by the name of the element. The element pattern contains another pattern within the braces. The contained pattern might be more elements, or attributes, or text, or all of them.
attribute
attribute name { text } - The keyword attribute is followed by the name of the attribute. For an attribute, the contained pattern would be text.
text
text - The keyword text does not have a name, nor a contained pattern. It just indicates text can be put here in the target document.

Reading assignment

Reading assignments are in Beginning XML, by DavidHunter, et al.
Read the chapter.

Chapter 6:  RELAX  NG