25.09.2014 Views

ZEND PHP 5 Certification STUDY GUIDE

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

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

XML and Web Services ” 187<br />

• Document Type Declaration: A set of instructions that describes the accepted<br />

structure and content of an XML file. Like entities, DTDs can either be externally<br />

defined or embedded.<br />

• Well-formed: An XML document is considered well-formed when it contains a<br />

single root level element, all tags are opened and closed properly and all entities<br />

(, &, ’, ") are escaped properly. Specifically, it must conform to all<br />

“well-formedness” constraints as defined by the W3C XML recommendation.<br />

• Valid: An XML document is valid when it is both well-formed and obeys a<br />

referenced DTD. An XML document can be well-formed and not valid, but it<br />

can never be valid and not well-formed.<br />

A well-formed XML document can be as simple as:<br />

<br />

Hello, World!<br />

This example conforms fully to the definition described earlier: it has at least one<br />

element, and that element is delimited by start and end tags. However, it is not valid,<br />

because it doesn’t reference a DTD. Here is an example of a valid version of the same<br />

document:<br />

<br />

<br />

Hello, World!<br />

In this case, an external DTD is loaded from local storage, but the declarations may<br />

also be listed locally:<br />

Licensed to 482634 - Amber Barrow (itsadmin@deakin.edu.au)<br />

<br />

<br />

Hello, World!<br />

In practice, most XML documents you work with will not contain a DTD—and, therefore,<br />

will not be valid. In fact, the DTD is not a requirement except to validate the

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

Saved successfully!

Ooh no, something went wrong!