Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 5. Creating XML Schemas > Creating Element Groups

Creating Element Groups

Say that I wanted 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, and you can name groups. 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:sequence>
        <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"/>
            <xsd:element ref="book"/>
            <xsd:group ref="booksAndMagazine"/>
        <xsd:choice>
    </xsd:sequence>
    <xsd:attribute name="borrowDate" type="xsd:date"/>
</xsd:complexType>


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial