Skip to Content
Real World XML
book

Real World XML

by Steven Holzner
January 2003
Beginner to intermediate content levelBeginner to intermediate
1200 pages
23h 42m
English
Peachpit Press
Content preview from Real World XML

Creating Choices

A choice lets you specify a number of elements, only one of which will be chosen. To create a choice in XML schemas, you use the <xsd:choice> element. The code that follows is an example. In this case, I'll change the transactionType type so that the borrower can borrow either several books or just one book. I do this by creating an <xsd:choice> element that holds both a <books> element and a <book> element. Note that, in this case, the <book> element needs to be made into a global element so I can refer to it in this choice. Thus, I remove it from the declaration of the <books> element, as you see here:

 xsd:complexType name="transactionType"> <xsd:sequence> <xsd:element name="Lender" type="address"/> <xsd:element name="Borrower" ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Inside XML

Inside XML

Steven Holzner
XML Hacks

XML Hacks

Michael Fitzgerald

Publisher Resources

ISBN: 0735712867Purchase book