02.06.2013 Views

XML Demystified

XML Demystified

XML Demystified

SHOW MORE
SHOW LESS

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

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

CHAPTER 4 <strong>XML</strong> Schema<br />

The customer element is a parent element that contains firstname and lastname<br />

elements, which is also similar to the one in the DTD. However, notice that these<br />

elements are defined as a string data type. This is unique to the <strong>XML</strong> schema. We’ll<br />

examine each component of an <strong>XML</strong> schema in detail in “An Inside Look at an<br />

<strong>XML</strong> Schema.”<br />

You save the <strong>XML</strong> schema to a file called customers.xsd. Next you’ll need to<br />

reference the customers.xsd file from within the <strong>XML</strong> document. You do this by<br />

inserting the xsi:schemaLocation attribute into the customers tag within the <strong>XML</strong><br />

document. We illustrate this in the next revision of the <strong>XML</strong> document. When the<br />

parser encounters the xsi:schemaLocation attribute, it reads the customers.xsd<br />

<strong>XML</strong> schema and then applies it to the <strong>XML</strong> document.<br />

<br />

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

Saved successfully!

Ooh no, something went wrong!