Name
rng:attribute — Matches an attribute
XML syntax example
<element name="date"> <attribute name="year"/> <attribute name="month"/> <attribute name="day"/> </element>
Compact syntax example
element date { attribute year { text }, attribute month { text }, attribute day { text } }
Attributes
name
An attribute name. If this name has a prefix, the namespace of the attribute is the namespace bound to that schema; if not, the attribute is in no namespace.
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 attribute
pattern
matches an attribute in an instance. If an attribute
element is empty, it is assumed
to contain a text pattern, so the following attribute patterns are
equivalent:
<attribute name="greeting" /> <attribute name="greeting"><text/></attribute>
The name
attribute is not
required; you can specify a name with the name
child element, or a name class with
an anyName
, an nsName
, or a choice
child element. In other words,
instead of this:
<attribute name="date"/>
You could use this:
<attribute> <name>date</name> </attribute>
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.
See also
§3, element
, 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.