Extensible Schemas

Sometimes, building an extensible schema is a matter of capturing existing practice in RELAX NG, while other times, the schema development comes before practice, and the schema developer has the opportunity to make a lot of choices. You often have to do your best to write an extensible schema for an existing XML vocabulary and are constrained by the existing vocabulary. Other times you can design whatever vocabulary seems appropriate to the information being described.

Working from a Fixed Result

In the case of a fixed result, the only way to manage extensibility relies on how named patterns are defined, much the same way that programmers’ decisions about how to define classes in object-oriented environments have a lot of impact on its extensibility. In this section, I will examine the major approaches to use when defining named patterns and start elements with extensibility in mind.

Providing a grammar and a start element

Let’s look back at our first schema, the Russian doll schema:

 <?xml version="1.0" encoding="utf-8" ?> <element xmlns="http://relaxng.org/ns/structure/1.0" name="library"> <oneOrMore> <element name="book"> <attribute name="id"/> <attribute name="available"/> <element name="isbn"> <text/> </element> <element name="title"> <attribute name="xml:lang"/> <text/> </element> <zeroOrMore> <element name="author"> <attribute name="id"/> <element name="name"> <text/> </element> <element name="born"> <text/> </element> <optional> <element name="died"> <text/> ...

Get RELAX NG now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.