RELAX NG by Eric van der Vlist will be published by O'Reilly & Associates (ISBN: 0596004214)

You are welcome to use our annotation system to give your feedback.


Referencing named patterns

Defining a named pattern is easy, as shown the example above, but referencing a named pattern rather than defining it again, is even simpler.

Using the XML syntax, references to named patterns that are defined elsewhere in the schema are done using a ref element. For instance, to define the author element, we'd use a reference to the name-element pattern:

      <element name="author">
       <attribute name="id"/>
       <ref name="name-element"/>
       <optional>
        <element name="born">
         <text/>
        </element>
       </optional>
       <optional>
        <element name="died">
         <text/>
        </element>
       </optional>
      </element>

To reference a named pattern in the compact syntax, you just use its name directly:

    element author {
      attribute id { text },
      name-element,
      element born { text }?,
      element died { text }?
    }

The same approach would be used for referencing the common-content named pattern:

      <element name="author">
       <ref name="common-content"/>
       <optional>
        <element name="died">
         <text/>
        </element>
       </optional>
      </element>

Or:

    element author {
      common-content,
      element died { text }?
    }

You are welcome to use our annotation system to give your feedback.
[Annotations for this page]
All text is copyright Eric van der Vlist, Dyomedea. During development, I give permission for non-commercial copying for educational and review purposes. After publication, all text will be released under the Free Software Foundation GFDL.