Triggers are a way of reaching back from a fully namespaced environment to elements which, although in the same namespace, require validation using a different schema. The standard provides a clear use case, that of an XHTML instance with embedded content from the XForms schema, but in the XHTML namespace. The requirement there is to validate the ancestors of XForms element against the XHTML schema, yet take the single element (and its children) and validate against the XForms schema, suitable amended to allow the given root element. Example 5.1 provides a very simple xml instance, Example 5.2 shows the NVDL script, and Example 5.3 shows the Schema which is used in all 3 sections generated.
The requirement is to validate the section element (and children) separately from
the sect element and its children. These
are two similar structures, the only variable being that one has a
title child, the other a head child.
A trigger is specified, with the single namespace used throughout and naming the two elements which will trigger the generation of a new section as a validation candidate.
Example 5.3. A simple trigger example - the schema used
<grammar xmlns="http://relaxng.org/ns/structure/1.0" ns="http://doc"> <start><choice> <ref name="doc"/> <ref name="section"/> <ref name="sect"/> </choice> </start> <define name="doc">
<element name="doc"> <empty/> </element> </define> <define name="section">
<element name="section"> <element name="title"><text/></element> <oneOrMore><element name="para"><text/></element></oneOrMore> </element> </define> <define name="sect">
<element name="sect"> <element name="head"><text/></element> <oneOrMore><element name="para"><text/></element></oneOrMore> </element> </define> </grammar>
The schema has the 3 entry points, doc, section and sect. With just the document element defined,
the validation would fail. Two more validation candidates are passed
to the validator with this schema, the section element and the sect element. The section is valid to the schema
in both cases.