pub enum Pattern {
Show 15 variants
Ref {
qname: String,
},
ParentRef {
qname: String,
},
ElementRef {
qname: String,
},
Def {
combiner: DefCombiner,
name: String,
body: Vec<Pattern>,
},
Element {
name: String,
body: Vec<Pattern>,
},
Attribute {
name: String,
body: Vec<Pattern>,
},
Start {
body: Vec<Pattern>,
},
Value(String),
Data(String),
Doc(String),
Combination {
op: CombineOp,
body: Vec<Pattern>,
},
Grammar {
name: String,
body: Vec<Pattern>,
},
Module {
name: String,
body: Vec<Pattern>,
},
Override {
module: Box<Pattern>,
replacements: Vec<Pattern>,
},
Text,
}Expand description
One node in the RelaxNG AST, mirroring Perl RelaxNG.pm’s
[$op, $name, @forms] arrays.
The names here line up 1:1 with the Perl op strings:
| Perl op | Rust variant |
|---|---|
ref | Pattern::Ref |
parentref | Pattern::ParentRef |
elementref | Pattern::ElementRef (added during simplify) |
def/defchoice/definterleave | Pattern::Def (combiner discriminates) |
element | Pattern::Element |
attribute | Pattern::Attribute |
start | Pattern::Start |
value | Pattern::Value |
data | Pattern::Data |
doc | Pattern::Doc |
combination | Pattern::Combination |
grammar | Pattern::Grammar |
module | Pattern::Module |
override | Pattern::Override (consumed by simplify) |
'#PCDATA' (string leaf) | Pattern::Text |
Variants§
Ref
Reference to a defined pattern. qname is the bare name during
scan and binding:name after simplify.
ParentRef
Reference to a parent grammar’s defined pattern (replaced by
Ref during simplify).
ElementRef
Reference to an element by tag name (introduced during simplify
when a Def resolves to a single Element).
Def
<define> (or combine="choice"|"interleave").
Element
<element name="...">CONTENT</element>.
Attribute
<attribute name="...">CONTENT</attribute>.
Start
<start>...</start>.
Value(String)
<value>X</value> — a literal value (typically for attributes).
Data(String)
<data type="X"/> — a typed datum.
Doc(String)
<a:documentation>X</a:documentation> — annotation text.
Combination
<group|interleave|choice|optional|zeroOrMore|oneOrMore|list>...</...>.
<mixed> is normalised here into Combination { Interleave, [Text, …] }.
Grammar
<grammar>...</grammar> — defines a fresh symbol scope. Replaced
by its start pattern after simplify.
Module
External / included module: contents from a separate schema file,
recorded in Relaxng::modules for documentation.
Override
<include>...</include> with override rules (consumed by simplify
— patches the inner Module and disappears).
Text
#PCDATA — text leaf.