Creating Sequences

By default, complex types in declare sequences of elements must appear in a conforming document. It turns out that you can also create sequences yourself using the <xsd:sequence> element.

For example, say that I want to let the borrower borrow not just books, but also a magazine. To do that, I can create a new group named booksAndMagazine. A group collects elements together. You can name groups, and you can then include a group in other elements using the <xsd:group> element and referring to the group by name:

 <xsd:complexType name="transactionType"> <xsd:element name="Lender" type="address"/> <xsd:element name="Borrower" type="address"/> <xsd:element ref="note" minOccurs="0"/> <xsd:choice> <xsd:element name="books" type="books"/> ...

Get Inside XML 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.