Next Up Previous Contents
Next: A.5 Marked sections
Up: A SGML - some of the details
Previous: A.3 Document type declaration subset
[ID index][Keyword index]

A.4 SGML entities

As described in Section 3.2, entity references are a mechanism for referring to characters, or longer pieces of text, which you cannot type on your keyboard, which must be escaped from the parser, or which you simply want to abbreviate.

As well as general entities, there are parameter entities. These can be referenced only within markup declarations, and hence are effectively restricted to the DTD. The only time you'd use them in a document instance would be within a marked section ( Section 3.5.2). The point of parameter entities is that a document author can define any entities they want in the declaration subset, without having to worry that they might conflict with declarations in the DTD.

A reference to an entity amp is of the form &. It is prefixed by the character & and suffixed by a semicolon. In fact, you can omit the trailing semicolon if the character following the entity name is not a name character - not a letter, number, hyphen or dot. Similarly, an ampersand not followed by a name-start character (upper- and lowercase letters) is recognised as an ampersand, and not a malformed entity reference. It is possibly bad to get into the habit of abbreviating entity references, but you might need to be aware that these features both exist and are legal.

The list of entities predefined by the Starlink general DTD is given in Table 1.

It is not an error to define an entity twice. In this case, the second definition is silently ignored.

You can define entities, including parameter entities, in the document's `declaration subset' (see Section 3.3), since these conceptually come before, and hence have priority over, definitions in the DTD. Also, SGML parsers usually allow on-the-fly definitions on the command line. However, resist resist resist the temptation to do clever things here, since it is easy to make your document unreadable and, a much more heinous crime, invalid.


Next Up Previous Contents
Next: A.5 Marked sections
Up: A SGML - some of the details
Previous: A.3 Document type declaration subset
[ID index][Keyword index]
The Starlink SGML Set
Starlink System Note 70
Norman Gray, Mark Taylor
21 April 1999. Release DR-0.7-13. Last updated 24 August 2001