Name
rng:element — Matches an element
XML syntax example
<element name="description"> <data type="string"/> </element>
Compact syntax example
element description { string }
Attributes
name
An element name. If this name has a prefix, the namespace of the element is the namespace bound to that schema. Otherwise, the namespace is specified by the nearest enclosing
ns
attribute.
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 element
pattern matches
an element in an instance. The name
attribute is not required—you can
specify a name with the name
child element or specify a name class with an anyName
, an nsName
, or a choice
child element. In other words,
instead of this:
<element name="description"/>
You could use this:
<element> <name>description</name> </element>
However, you cannot use the name
attribute and a name
child element at the same time; they
are mutually exclusive. There is no distinction between the name
attribute and a name
child element in the compact syntax.
If multiple child patterns are present, they are treated as if
wrapped by a group
pattern.
See also
§1, attribute
, name
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.