Name

rng:grammar — Container for the definitions of named patterns

XML syntax example

<grammar xmlns="http://relaxng.org/ns/structure/1.0">

<start>
 <element name="cd">
  <attribute name="title"/>
  <optional>
   <attribute name="artist"/>
  </optional>
  <ref name="content"/>
 </element>
</start>

<define name="content">
 <element name="playlist">
  <oneOrMore>
   <element name="song"><text/></element>
  </oneOrMore>
 </element>
</define>

</grammar>

Compact syntax example

start = element cd {
 attribute title { text }, attribute artist { text }?,
 content
}
content = element playlist { element song { text }+ }

Parents

attribute, choice (( ) and |), define (name of pattern followed by =), element, except (-), group (( ) and ,), interleave (&), list, mixed, oneOrMore (+), optional (?), start (start followed by =), zeroOrMore (*)

Description

A grammar pattern acts as a container for define elements, which define named patterns, and for a start element, which specifies the pattern that must be matched in order for the grammar element to be matched. (A grammar pattern may also contain only a section of schema.) It is common to use a grammar pattern as the document element of a RELAX NG schema, and in the compact syntax, a grammar pattern is assumed if the schema consists of definitions using =.

See also

§4, §9, §13, define, start

Get XML Pocket Reference, 3rd Edition 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.