
162 • XML & Related Technologies
4.3.2 Making Choices
We know that in the case of a DTD, we can use the pipe (|) symbol to signify selection. In schema, the
corresponding functionality is achieved by using the xsd:choice syntax. When we embed more than one
element inside a choice boundary, exactly one of them must occur in the XML document.
For example, suppose that we want to store the information about the result of examination as Pass or
Fail along with the percentage of marks obtained. Clearly, only one of these should be allowed. We can make
use of the choice element, as shown in Figure 4.26.
Schema file (result.xsd)
<?xml version=”1.0”?> ...