|
|
|
SCWD home | SCJP home | XML books
Entities
-
All XML documents are comprised of units of storage - entities.
-
Document entity serves as the starting point for an XML parser.
-
External and internal subsets of DTD are also entities, but unnamed ones.
- Main categories of entities:
- Internal vs External
- Parsed vs Unparsed
- General vs Parameter
-
Internal entities can only be parsed
-
External entities can be both parsed/unparsed
-
General entities can be both parsed/unparsed
-
Parameter entities are always parsed entities and so can be internal or external
-
General entities are referenced by using entity reference "&name;" Parameter entities are referenced as "%name;"
- Unparsed entities:
- May or may not be text
- Need not be XML text
- Must have associated notation
- Can only be used as the value of an attribute having ENTITY/ENTITIES type
-
The defining declaration should precede any references to the entity
- General entities cause fatal XML Parse errors if:
- Any reference to an unparsed entity
- Any char or general entity reference in DTD except within an entity or attribute value
- Any reference to an external entity from within an attribute value
-
Unparsed entities are always external
-
Entities can never be empty
-
An entity reference must not contain the name of an unparsed entity.
- Motivation for entities:
- To insert special characters
- For repeatable text
- To include external files, including ones which have non-XML content
SCWD home | SCJP home | XML books
|