Well we have pretty much let the cat out of the bag already. We have
shown several examples of entity references above.
In short, Entity References refer to the key that unlocks an entity whch has been declared
in an Entity Declaration. Entity References follow the simple syntax of:
- Entities MUST be declared in an XML document before they are referenced.
- Note that there may not be any whitespace embedded in an entity reference. In other
words, & letterhead; or &letterhead ; will cause errors.
- Though entities may refer to other entities, they may not be
self-referential. So they may not reference other entities that
reference them in return.
- References to entities may not appear in the DOCTYPE declaration
- The text that the entity references must be well-formed XML.
As you might expect parameter entity references work much like
general entity references. In this case, we use a "%" sign
instead of a "&".
Now, you have already seen that entity references can take the place of regular character
data and you have seen how useful that is. Before we leave the subject, I would only
mention that you could also use entity references within tag attributes. For example,
consider the following:
<INVOICE CLIENT = "&IBM;" PRODUCT = "&PRODUCT_ID_8762;" QUANTITY = "5">
- You may not reference an external entity from within element attributes.
- The referenced text may not contain the < character because it would
cause a well-formed error in the element when replaced.
Previous Page |
Next Page |
Table of Contents