|
Microsoft Word Applied xml a toolkit for Programmers Wiley docBog'liq Ceponkus, Hoodbhoy - Applied XML - Toolkit for Programmers
Entity Declarations
Entities become more and more important as your applications grow more complex. As
we mentioned before, entities are essentially objects that you can point to in your XML
document using an entity reference. The actual declaration of the entity is made in the
DTD.
Entities have their own types as well. While we talked briefly about internal and external
entities in the entity reference section, we need to mention that both of these can
furthermore be subsets of two types of entities:
Parameter Entities.
Entities that are used only inside the DTD itself (sort of shorthand
for programming ease). Their general form is:
<
!ENTITY %
entity_name
"entity_type"
>
General Entities.
Entities that are used in the XML document itself (that is, under the
root element). Their general form is:
<
!ENTITY
entity_name
"entity"
>
Realistically, you most likely will be dealing with external entities of the general form.
However, in the interest of completion, we’ve described each type.
Internal General Entity Declaration
As we mentioned before, a general entity is one that is used in the XML document itself
as opposed to being referenced internally in the DTD. One common use of internal
general entities is creating a shortcut to typing long words/acronyms. Here’s an example
(Note: this is a complete XML document with an internal DTD; keywords are in boldface):
<
!ELEMENT
mail (letter)+>
<
!ENTITY
SDS "Same Day Service">
<
!ENITITY
NDS "Next Day Service">
<
!ENTITY
Alex "Alex Ceponkus, Canada">
<
!ENTITY
Faraz "Faraz Hoodbhoy, USA">
<
!ELEMENT
letter (to, from, content+)+>
<
|
| |