by Eric van der Vlist is published by O'Reilly & Associates (ISBN: 0596004214)

The choice Pattern

Let's add some flexibility to the name element so we can accept:






To express this flexibility, use a choice pattern that accepts either a text node or a group of three elements (one of which is optional):

<element name="name">
   <element name="first"><text/></element>
     <element name="middle"><text/></element>
   <element name="last"><text/></element>

The compact syntax uses a pipe, or logical "or" character (|) to denote choices:

 element name {
   element first{text},
   element middle{text}?,
   element last{text}

Note that you have to use parentheses to mark the boundary of the group pattern.

This text is released under the Free Software Foundation GFDL.