Name

choice (in the context of a pattern) — choice pattern

Synopsis

element choice
{
 (
 attribute ns { text }?,
 attribute datatypeLibrary { xsd:anyURI }?,
 attribute * - (rng:* | local:*) { text }*
 ),
 (
 ( element * - rng:* { ... }* )
 & (
 element element { ... }
 | element attribute { ... }
 | element group { ... }
 | element interleave { ... }
 | element choice { ... }
 | element optional { ... }
 | element zeroOrMore { ... }
 | element oneOrMore { ... }
 | element list { ... }
 | element mixed { ... }
 | element ref { ... }
 | element parentRef { ... }
 | element empty { ... }
 | element text { ... }
 | element value { ... }
 | element data { ... }
 | element notAllowed { ... }
 | element externalRef { ... }
 | element grammar { ... }
 )+
 )
}

Class

pattern

May be included in

attribute, choice, define, element, except, group, interleave, list, mixed, oneOrMore, optional, start, zeroOrMore

Compact syntax equivalent

pattern|pattern

Description

The choice pattern defines a choice between different patterns; it matches a node if, and only if, at least one of its subpatterns matches this node.

Example

<element name="name"> <choice> <text/> <group> <element name="first"><text/></element> <optional> <element name="middle"><text/></element> </optional> <element name="last"><text/></element> </group> </choice> </element> <attribute name="available"> <choice> <value>true</value> <value>false</value> <value>who knows?</value> </choice> </attribute> <start> <ref name="libraryElement"/> <ref name="bookElement"/> </start> ...

Get RELAX NG 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.