Name
rng:parentRef — References a named pattern in a parent grammar
XML syntax example
<grammar xmlns="http://relaxng.org/ns/structure/1.0">
<start>
<choice>
<ref name="type" />
<ref name="alt" />
</choice>
</start>
<define name="type">
<element name="type">
<list>
<choice>
<value>html</value>
<value>xhtml</value>
<value>xml</value>
</choice>
</list>
</element>
</define>
<define name="alt">
<grammar>
<start>
<choice>
<element name="method">
<list>
<choice>
<value>text</value>
<value>other</value>
</choice>
</list>
</element>
<parentRef name="type"/>
</choice>
</start>
</grammar>
</define>
</grammar>
Compact syntax example
start = type | alt type = element type { list { "html" | "xhtml" | "xml" } } alt = grammar { start = element method { list { "text" | "other" } } |parent
type
}
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
The parentRef
pattern
references a named pattern in a parent grammar—that is, a grammar
that directly or indirectly contains the current grammar. parentRef
extends the scope of the current
grammar to definitions in the parent grammar.
See also
§13, externalRef
, ref
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.