26.01.2019 Views

XML Simplified

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Module 4<br />

<strong>XML</strong> Schema<br />

DTD File for Book.xml<br />

Concepts<br />

The following code demonstrates a DTD file called "Book.dtd" that defines the elements of the<br />

Book.xml document.<br />

Code Snippet:<br />

<br />

<br />

<br />

<br />

The first line of code defines the Book element to be the root element which in turn encloses three child<br />

elements: 'Title', 'Author', and 'Chapter'. The rest of the block defines the 'Title', 'Author', and 'Chapter'<br />

elements to be of type "#PCDATA".<br />

<strong>XML</strong> Schema for Book.xml<br />

The following code demonstrates that the corresponding <strong>XML</strong> Schema file called "Book.xsd" defines the<br />

elements of the <strong>XML</strong> document Book.xml.<br />

Code Snippet:<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

The Book element is a complex type because it encloses other elements. The child elements Title,<br />

Author, Chapter are simple types because they do not contain other elements.<br />

Version 1.0 © Aptech Limited<br />

<strong>XML</strong> <strong>Simplified</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!