7.7 Internal Entities
- Indirect references to values are called entities.
- Entities defined within DTDs are said to be internal.
- Two types of entities:
|
|
| General | content to be retrieved within XML documents |
|
|
| Parameter | content to be retrieved within DTDs |
General Entities:
| Declaration | <!ENTITY name value> |
| Reference in CDATA and PCDATA | &name; |
<!ENTITY cse "cse.ohio-state.edu" >
...
<email>
<to>you@&cse;,
they@cse.ohio-state.edu
</to>
<from>me@&cse;</from>
</email>
Parametric Entities:
| Declaration | <!ENTITY % name value> |
| Reference | %name; |
<!ELEMENT eat (#PCDATA) >
<!ELEMENT sleep EMPTY >
<!ENTITY % how "eat | sleep" >
<!ELEMENT live (%how;)* >
...
<live>
<eat>bread</eat>
<eat>cake</eat>
<sleep />
</live>
The interface DTDHandler provides the following method.
void internalEntityDecl(String name, String value)