| Previous | Next
General Entity DeclarationsAs you learned in , XML predefines five entities for your convenience:
The DTD can define many more. This is useful not just in valid documents, but even in documents you don't plan to validate. Entity references are defined with an <!ENTITY super "supercalifragilisticexpialidocious"> Once that's done, you can use Entities can contain markup as well as text. For example, this declaration defines <!ENTITY footer '<hr size="1" noshade="true"/> <font > <a href="./">O'Reilly Home</a> | <a href="sales/tutorialstores/">O'Reilly Bookstores</a> | <a href="order_new/">How to Order</a> | <a href="anonymous/contact.html">O'Reilly Contacts</a><br> <a href="http://web.archive.org/web/international.anonymous.com/">International</a> | <a href="anonymous/about.html">About O'Reilly</a> | <a href="affiliates.html">Affiliated Companies</a> </font> <p> <font > copyleft 2000, O'Reilly & Associates, Inc.<br/> <a href="mailto:webmaster@mailinator.com">webmaster@mailinator.com</a> </font> </p> '> The entity replacement text must be well-formed. For instance, you cannot put a start-tag in one entity and the corresponding end-tag in another entity. The other thing you have to be careful about is that you need to use different quote marks inside the replacement text from the ones that delimit it. Here we've chosen single quotes to surround the replacement text and double quotes internally. However, we did have to change the single quote in "Anonymous" to the predefined general entity reference General entities insert replacement text into the body of an XML document. They can also be used inside the DTD in places where they will eventually be included in the body of an XML document, for instance in an attribute default value or in the replacement text of another entity. However, they cannot be used to provide the text of the DTD itself. For instance, this is illegal: Shortly, we'll see how to use a different kind of entity--the parameter entity--to achieve the desired result. |