Name
rng:define — Defines a named pattern
XML syntax example
<grammar xmlns="http://relaxng.org/ns/structure/1.0"> <start> <ref name="greeting"/> </start> <define name="greeting"> <choice> <element name="hello"><text/></element> <element name="hi"><text/></element> <element name="wazzup"><text/></element> </choice> </define> </grammar>
Compact syntax example
start = greeting greeting = element hello { text } | element hi { text } | element wazzup { text }
Attributes
combine
(|=
forchoice
,&=
forinterleave
)Valid values are
choice
orinterleave
.choice
means multipledefine
elements are combined as a choice;interleave
means multipledefine
elements are combined by interleaving.name
Specifies the name assigned to the pattern; must not have a prefix.
Parents
div
, grammar
, include
Description
The define
element defines
a named pattern that can be referenced by ref
elsewhere in the schema or by parentRef
to reference a named pattern in
a parent schema. If define
is in
an include
, it redefines any
named pattern of the same name in the included schema unless the
combine
attribute is used (if you
want to combine, you need to locate your new definitions
outside of the include
pattern). If multiple child
patterns are present, they are treated as if wrapped by a group
pattern. In the compact syntax,
definitions can constitute the whole of a schema, as if a grammar
pattern were present. Also in the compact syntax, choice
and interleave
combined definitions are
expressed using |=
and &=
rather than simply ...
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.