General entities allow you to create document-wide entities and look something like:
<!ENTITY % NAME "text that you want to be represented by the entity">
In the real world, you might have something that looked like the following:
<!ENTITY % full_name "Diego Ramirez Valenzuela Martinez Perez the 5th">
Entities are referenced using a
%ENTITYNAME;
such as
<!ENTITY % TAG_NAMES "NAME | EMAIL | PHONE | ADDRESS">
<!ELEMENT BUSINESS_CONTACT (%TAG_NAMES; | COMPANY_NAME)>
Make sure you remember the semi-colon. I forget this all the time :)
NOTE: You can specify an entity that has text defined
external to the document by using the SYSTEM keyword such as:
<!ENTITY % license_agreement
SYSTEM "http://www.mydomain.com/license.xml">
In this case, the XML processor will replace the entity reference with the contents
of the document specified.
|
Be careful that when defining entities, that you define them before
using them. Thus, the following would be invalid because the TAG_NAMES
alias is defined after it is used.
<!ELEMENT PERSONAL_CONTACT (%TAG_NAMES; | BIRTHDAY)>
<!ELEMENT BUSINESS_CONTACT (%TAG_NAMES; | COMPANY_NAME)>
<!ENTITY % TAG_NAMES "NAME | EMAIL | PHONE | ADDRESS">
|