Java Reference
In-Depth Information
Defining Parameter Entities
You will often need to repeat a block of information in different places in a DTD. A parameter entity
identifies a block of parsed text by a name that you can use to insert the text at various places within a
DTD. Note that parameter entities are only for use within a DTD. You cannot use parameter entity
references in the body of a document. You declare general entities in the DTD when you want to repeat
text within the document body.
The form for a parameter entity is very similar to what we saw for general entities except that a %
character appears between ENTITY and the entity name separated from both by a space. For example,
it is quite likely that you would want to repeat the x and y attributes that we defined in the
<position> element in the previous section in other elements. We could define a parameter entity for
these attributes and then use that wherever these attributes should appear in an element declaration.
Here's the parameter entity declaration:
<!ENTITY % coordinates "x CDATA #REQUIRED y CDATA #REQUIRED">
Now we can use the entity name to insert the x and y attribute definitions in an attribute declaration:
<!ATTLIST position %coordinates; >
A parameter entity declaration must precede its use in a DTD.
The substitution string in a parameter entity declaration is parsed, and can include parameter and
general entity references. As with general entities, a parameter entity can also be defined by a reference
to a URI containing the substitution string.
Other Types of Attribute Value
There are a further eight possibilities for specifying the type of the attribute value. We won't go into
detail on these but, so you can recognize them, they are:
ENTITY
An entity defined in the DTD. An entity here is a name identifying an unparsed
entity defined elsewhere in the DTD by an ENTITY tag. The entity may or may
not contain text. An entity could represent something very simple such as &lt; ,
which refers to a single character, or it could represent something more
substantial such as an image.
ENTITIES
A list of entities defined in the DTD separated by spaces.
ID
An ID is a unique name identifying an element in a document. This is to enable
internal references to a particular element from elsewhere in the document.
IDREF
A reference to an element elsewhere in a document via its ID.
IDREFS
A list of references to IDs separated by spaces.
NMTOKEN
A name conforming to the XML definition of a name. This just says that the
value of the attribute will be consistent with the XML rules for a name.
NMTOKENS
A list of name tokens separated by spaces.
Search WWH ::




Custom Search