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.


Name

define — Named pattern definition

Class:

define-element

Synopsis

element define
{
   attribute name { xsd:NCName },
   ( attribute combine { "choice" | "interleave" }? ),
   (
      attribute ns { text }?,
      attribute datatypeLibrary { xsd:anyURI }?,
      attribute * - (rng:* | local:*) { text }*
   ),
   (
      ( element * - rng:* { ... }* )
    & (
         element element { ... }
       | element attribute { ... }
       | element group { ... }
       | element interleave { ... }
       | element choice { ... }
       | element optional { ... }
       | element zeroOrMore { ... }
       | element oneOrMore { ... }
       | element list { ... }
       | element mixed { ... }
       | element ref { ... }
       | element parentRef { ... }
       | element empty { ... }
       | element text { ... }
       | element value { ... }
       | element data { ... }
       | element notAllowed { ... }
       | element externalRef { ... }
       | element grammar { ... }
      )+
   )
}

May be included in:

div, grammar, include.

Compact syntax equivalent:

identifier assignMethod pattern

Description:

When define is embedded in a grammar, it defines a named pattern or combines a new definition with an existing one. Named patterns are global to a grammar and can be referenced by ref in the scope of their grammar and by parentRef in the scope of the grammars directly embedded in their grammar.

When define is embedded in include, the new definition is a redefinition. It replaces the definitions from the included grammar unless a combine attribute is specified, in which case the definitions are combined.

Restrictions:

Named patterns are always global and apply only to patterns. It is not possible to define and make reference to non-patterns such as class names or datatype parameters.

Example:

  <define name="born-element">
    <element name="born">
      <text/>
    </element>
  </define>

  <define name="book-content" combine="interleave">
    <attribute name="id"/>
    <attribute name="available"/>
    <ref name="isbn-element"/>
    <ref name="title-element"/>
    <zeroOrMore>
      <ref name="author-element"/>
    </zeroOrMore>
    <zeroOrMore>
      <ref name="character-element"/>
    </zeroOrMore>
  </define>
  
  <define name="isbn-element" combine="choice">
    <notAllowed/>
  </define>
      

Attributes:

combine

The combine attribute specifies how multiple definitions of a named pattern should be combined together. The possible values are choice and interleave.

When the combine attribute is specified and set to choice, multiple definitions of a named pattern are combined in a choice pattern. When the combine attribute is specified and set to interleave, multiple definitions of a named pattern are combined in an interleave pattern.

Note that it is forbidden to specify more than one define with the same name and no combine attribute or multiple define with different values of combine attribute.

datatypeLibrary

The datatypeLibrary attribute defines the default datatype library. The value of datatypeLibrary is inherited.

name

The name attribute specifies the name of the named pattern.

ns

The ns attribute defines the default namespace for the elements defined in a portion of a schema. The value of ns is inherited.


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.