Structured Text
SGML
allows documents to include markup that describes the structure of the document, and provides a method of
specifying the desired structure for a document.
For example, the Complete Works of Shakespeare might be assigned the logical structure shown below.

This logical structure might then be described in an SGML DTD as:
<!--
A work has a header identifying some known properties of the work and body -->
<!ELEMENT WORK - - (HEADER, BODY)>
<!--The header collects together some useful information about a work. Id is a unique numeric identifier
for the work. Author identifies the probable author of the work. -->
<!ELEMENT HEADER - - (ID, AUTHOR)>
<!ELEMENT ID - - (#PCDATA)>
<!ELEMENT AUTHOR - - (#PCDATA)>
<!-- The body of each work has a title, and a possible scenario. It then has acts followed by an optional
list of characters. Songs, drama and asides may occur anywhere within the body -->
<!ELEMENT BODY - - (TITLE, SCENARIO?, ACT*,CHARACTERS?) +(ASIDE)>
<!ELEMENT TITLE - - (#PCDATA)>
<!--The character list describes (sets of related) characters in the play Characters may be related either
because they form a natural collection or because of a natural relationship between them. -->
<!ELEMENT CHARACTERS - - (RELATED | CHARACTER)*>
<!ELEMENT RELATED - - (COLLECTION?, GROUP?, BECAUSE?)>
<!ELEMENT COLLECTION - - (#PCDATA)>
<!ELEMENT GROUP - - (CHARACTER+)>
<!ELEMENT BECAUSE - - (#PCDATA)>
<!--Each character has zero or more names (i.e. titles), a possible role within the play, and zero or more
short handles used to identify this character as a speaker -->
<!ELEMENT CHARACTER - - (NAME*, ROLE?, SHORT*)>
<!ELEMENT NAME - - (#PCDATA)>
<!ELEMENT ROLE - - (#PCDATA)>
<!ELEMENT SHORT - - (#PCDATA)>
<!--Each play has a scenario (where it was set) and a collection of acts Each act contains one or more
scenes. Acts and scenes have numbers or text which distinguish them within a play. Scenes have an associated
set (instructions for the stage setting for the scene) -->
<!ELEMENT SCENARIO - - (#PCDATA)>
<!ELEMENT ACT - - (ACTNO,SCENE+) +(SONG, DRAMA)>
<!ELEMENT ACTNO - - (#PCDATA) -(SONG, DRAMA)>
<!ELEMENT SCENE - - (SCENENO, SET?, SPEECH*)>
<!ELEMENT SCENENO - - (#PCDATA) -(SONG, DRAMA)>
<!ELEMENT SET - - (#PCDATA) -(SONG, DRAMA)>
<!-- Each speech has zero or more speakers, and either involves singing or saying something. An aside is any
parenthetical instructions, comment etc. Song is anything to be sung. Drama is anything which is to be
presented by the actors. -->
<!ELEMENT SPEECH - - (SPEAKER*, (SAID | SONG))>
<!ELEMENT SPEAKER - - (#PCDATA)>
<!ELEMENT SAID - - (#PCDATA)>
<!ELEMENT ASIDE - - (#PCDATA)>
<!ELEMENT SONG - - (#PCDATA)>
<!ELEMENT DRAMA - - (#PCDATA)>
|