Annotation for Applications
As mentioned in the introduction to this chapter, common uses of annotations by applications include preprocessing instructions, helpers for generating other schemas out of a RELAX NG schema, and extensions of RELAX NG itself.
Annotations for Preprocessing
Bob DuCharme has proposed an interesting application of annotation for preprocessing. He says that annotation can derive specific schemas by the restriction of a generic schema. The benefits of this approach are that it is extremely simple and that it provides a straightforward workaround to the lack of derivation by restriction (a W3C XML Schema feature) in RELAX NG. It is language-neutral and can be applied to other schema languages such as W3C XML Schema: it is much simpler than the derivation by restriction feature built into the language.
The idea behind his proposal is to add annotations in elements that
need to be removed in a variant of the schema. You then use these
annotations to generate the different variants using an XSLT
transformation. Each variant is called a stage.
The list of the available stages is declared in an
sn:stages element. For each element that is
conditional, the list of the stages in which it needs to be kept is
declared through an
Because this technique uses annotations, ...