Chapter 13. Annotating Schemas

RELAX NG annotations are elements and attributes from other namespaces that are incorporated into RELAX NG schemas. In Chapter 12, you learned how to use extensibility with schemas and instance documents. Up to now, we’ve been relying on elements and attributes whose syntax and meaning are precisely defined within the RELAX NG specification. Annotations provide a very different form of extensibility; you’re creating extensions to the RELAX NG vocabulary itself.

The scope of applications based on annotations can be as wide as your imagination. To give your imagination a place to build, be aware that there are some common structures in the existing usage of schema annotation. There are annotations for documentation purposes, and there are annotations for applications. Within the category of annotations for applications, three more categories can be distinguished:

  • Preprocessing annotations that generate a variety of schemas from a common one

  • Annotations that help to generate something (from documentation to a whole host of other clever things you may never have considered) from a RELAX NG schema

  • Annotations that extend the features of RELAX NG

Armed with this glimpse of the possible, we need to explore the syntax for embedding annotations within RELAX NG schemas.

Get RELAX NG 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.