The first steps with PSGML

Now you should have a look at an SGML document with PSGML. We'll start with a very simple example provided by Paul Prescod's DSSSL introduction (see Further Reading). This example does not use an external DTD. The necessary files to resolve links to external DTDs will be added later. There is no need to understand the syntax of the DTD at the moment, simply type it or copy it to your document.

Note: If you prefer to start with an XML document right away, you may peek ahead to the chapter about xslide. There you'll find an XML version of the SGML document described here.

Restart Emacs to apply the latest changes to your _emacs and open a new SGML document: Type C-x C-f ~/test.sgml to create the document test.sgml in your home directory (you may as well type the full path of a file in any other convenient directory). Emacs should load the SGML mode (check the modeline close to the bottom of the Emacs window). Now type or paste the following DTD into the new buffer:

      
<!DOCTYPE HTMLLite [
<!ELEMENT HTMLLite O O (H1|P)* >
<!ELEMENT (H1|P) - - (#PCDATA|EM|STRONG)* >
<!ELEMENT (EM|STRONG) - - (#PCDATA) >
]>
      
   

As you just have created the DTD, PSGML is not yet aware of it (when you load an existing SGML file, PSGML will automatically parse the DTD due to a setting in your _emacs file). Press C-c C-p to parse the DTD now. Check your DTD again if PSGML issues an error.

Now place the cursor at the end of the buffer and start to append the contents of the document to the prolog. Use the menu command Markup->Insert Element to enter the first element. You will notice that PSGML offers only one possible element to insert: HTMLLite. Accept this and insert another element right where you are. This time you will see that you can either insert a H1 or a P element. You can enter some text between the H1 or P start and end tags. Try to insert another element when the cursor is inside the text in a H1 or P element. This will allow you to insert either a STRONG or an EM element, which again can hold some text. Try also the keyboard shortcut for inserting an element, C-c C-e. You will be prompted for the name of an element. Either enter the full name of an element, the first letters and then the tab key, or simply press the tab key twice to see a list of possible tags at the given location. Note that you don't have to enter hard returns or to manually indent, PSGML takes care of this.

When you're done, save your document by pressing C-c C-s. A valid HTMLLite document may look like this:

      
<htmllite>
<h1>Character of Constantine</h1>
<p>The person, as well as the mind, of Constantine had been enriched by nature
with her choicest endowments.</p>
<p>His stature was <em>lofty</em>, his countenance <em>majestic</em>, his
deportment <em>graceful</em>; his strength and activity were displayed in
every manly exercise, and, from his earliest youth to a very advanced season
of life, he preserved the vigour of his constitution by a
<strong>strict</strong> adherence to the domestic virtues of chastity and
temperance.</p>
</htmllite>
      
   

You should also have noticed that PSGML performs syntax-highlighting: Start/end tags and other language-related constructs are shown in different colors to increase readability. Do not delete your test document yet, because you may wish to reuse it in the next chapter.