A sample SUN is illustrated in Figure 2.
<!DOCTYPE sun PUBLIC "-//Starlink//DTD Starlink SUN//EN"> <title>The Starlink SGML set <author email='norman@astro.gla.ac.uk' webpage='http://www.astro.gla.ac.uk/users/norman' affiliation='University of Glasgow' id=ng >Norman Gray <docnumber>1234 <history> <version number=0 date='21-APR-1999' author=ng>Initial version </history> <abstract> This is a sample SUN </abstract> <sect id=intro export>Introduction <p>Starlink SUNs are easy to write. |
Figure 2: A simple sample SUN |
Features to note:
<!DOCTYPE sun PUBLIC "-//Starlink//DTD Starlink
SUN//EN">
, which states which DTD this document claims to be
conformant to, in this case the Starlink SUN document type.author
or sect
, and these in turn contain further data,
such as a sequence of characters (`Norman Gray') in the case of the
author
element, or further elements (the version
element)
in the case of the history
element. Elements are delimited by
`opening tags' like <abstract>
and `closing tags'
like </abstract>
.[Note 3]author
element has the characters `Norman Gray' as its
content and a list of strings such as an email address as its
attributes.abstract
element for example)
are closed (ie, have closing tags to match their opening tags), but
the majority are not. This is because the DTD tells
the parser that a title
element cannot contain an author
element, so the appearance of the latter implicitly finishes the
former.copyright
element is optional, and it turns out
that the only required content of a document
body is the abstract! Also, the only required attribute of the
author
element is the id
attribute.<sun> <docinfo> <title>The Starlink SGML set</title> <authorlist> <author email="norman@astro.gla.ac.uk" webpage="http://www.astro.gla.ac.uk/users/norman" affiliation="University of Glasgow" id="ng">Norman Gray</author> </authorlist> <docnumber>1234</docnumber> <history> <version number="0" date="21-APR-1999" author="ng"> <px>Initial version</px> </version> </history> </docinfo> <docbody> <abstract> <px>This is a sample SUN</px> </abstract> <sect id="intro" export> <subhead> <title>Introduction</title> </subhead> <p>Starlink SUNs are easy to write.</p> </sect> </docbody> </sun> |
Figure 3: A SUN document with all tags in place, the normalised version of the document in Figure 2. |
In Figure 3, note that the actual content of
the abstract
element is one or more px
elements (a
slightly restricted variant of the standard p
paragraph
element), and that the sect
element contains a subhead
element, and contains the paragraphs which constitute it (note
that this is a significant difference from HTML, where the heading
elements hn
contain only a section title). You will rarely
have to be aware of these `hidden' tags when you are creating a
document, but it will occasionally be
useful to know that these tags are there somewhere, and that you're
glad you don't have to type all of them.
In fact, when I explain the document structure below, I will do it in terms
of the elements which are `really' there.
`Markup minimisation', which is SGML's name for this, was introduced to SGML to make typing less onerous. Personally, I like this, since it seems to make the document look less cluttered, and so I have designed the DTD to support this quite extensively. The minimisation is completely optional, however, and you may insert all the tags if you prefer. SGML-aware editors (see Section 6.5) typically insert all tags. See also Section 3.4. XML omits this markup-minimisation feature.
You can see from Figure 3 that the `top-level'
element of this document is sun
. The top-level element of SSN
documents is ssn
, and similarly for the other Starlink document
types (see Section 4.1). These different document types
are broadly the same, but the
SSN document type does not, by default, include elements for documenting
programming code, and the MUD document type has a docdate
element instead of a docnumber
and a history
. A
particular document can re-enable such omitted features using the
mechanism in Section 4.1. The SUN
document type is the most general. The top-level sun
element
has only two `children', docinfo
, which contains the document
information such as its author, number, and so on, and docbody
,
which contains the actual content of the document.