pub enum Pattern {
Show 14 variants
Empty,
NotAllowed,
Text,
Value {
datatype: String,
text: String,
},
Data {
datatype: String,
params: Vec<(String, String)>,
},
List(Arc<Pattern>),
Element {
name: NameClass,
child: Arc<Pattern>,
},
Attribute {
name: NameClass,
child: Arc<Pattern>,
},
Group(Arc<Pattern>, Arc<Pattern>),
Interleave(Arc<Pattern>, Arc<Pattern>),
Choice(Arc<Pattern>, Arc<Pattern>),
OneOrMore(Arc<Pattern>),
Ref(String),
After(Arc<Pattern>, Arc<Pattern>),
}Expand description
A RelaxNG pattern. See module docs for what’s supported.
Patterns are wrapped in Arc so derivative-style transformations
can share subtrees cheaply across alternatives.
Variants§
Empty
<empty/> — matches the empty content sequence.
NotAllowed
<notAllowed/> — matches nothing.
Text
<text/> — matches any sequence of text.
Value
<value type=...>X</value> — text content must equal X
after whitespace normalisation per the datatype.
Data
<data type="..."><param name=...>...</param>...</data> —
text content must validate against the named datatype.
List(Arc<Pattern>)
<list> — whitespace-tokenize the text, match each token
against the inner pattern.
Element
<element name="X">child</element>.
Attribute
<attribute name="X">child</attribute>.
Group(Arc<Pattern>, Arc<Pattern>)
<group> — sequential composition.
Interleave(Arc<Pattern>, Arc<Pattern>)
<interleave> — both patterns must match, in any order.
Choice(Arc<Pattern>, Arc<Pattern>)
<choice> — match either alternative.
OneOrMore(Arc<Pattern>)
<oneOrMore> — match inner one or more times.
Ref(String)
<ref name="X"/>.
After(Arc<Pattern>, Arc<Pattern>)
Internal: a pattern that matches a fixed remaining set of children, produced by derivatives. Equivalent to a successfully-matched-so-far state.