Name

identifier assignMethod pattern — Named pattern definition

Synopsis

define ::= 
identifier 
                     assignMethod 
                     pattern
                  

Restrictions

pattern

May be included in

div, grammar, include

XML syntax equivalent

define

Description

When identifier assignMethod pattern 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 identifier assignMethod pattern is embedded in include, the new definition is a redefinition. It replaces the definitions from the included grammar unless a combine attribute is specified. If one is, the definitions are combined.

The combination is defined using the assignMethod, which may take the values: = (definition), &= (combination by interleave), or |= (combination by choice).

Restrictions

Named patterns are always global and apply only to patterns. It isn’t possible to define or make reference to nonpatterns such as class names or datatype parameters.

Example

date-element = element born { xsd:data }

date-element |= element died { xsd:date }

Get RELAX NG 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.