<!DOCTYPE Book PUBLIC "-//Davenport//DTD DocBook V3.0//EN">
<book>
	<title>
		A quick introduction to SGML, DocBook and Jade for those who just want to use it
	</title>
	<bookinfo>
		<bookbiblio>
			<authorgroup>
				<author><firstname>Michael</firstname><surname>Hope</surname></author>
			</authorgroup>
			<productname>
				Quick intro to DocBook
			</productname>
			<pubdate>July 3rd 1998</pubdate>
			<copyright>
				<year>1998</year>
				<holder>Michael Hope</holder>
				</copyright>
			<abstract>
				<para>
					This document is designed for people like me who have heard about SGML and DocBook
and about all the great things it can do but who don't want to wade through the 
language specification to understand how to write a simple document.  I'm only a SGML
newbie, so this is by no means complete or reliable but hopefully someone will find
it usefull.  It assumes only a knowledge of HTML and tags and builds from there
by providing a link to the required software, a template to fill in and some pointers
to more advanced texts.
				</para>
			</abstract>
		</bookbiblio>
	</bookinfo>
	<toc></toc>
	<preface id="PREFACE">
		<title>Preface</title>
		<para>
			First up I should clear up some misconceptions that I originally had.  SGML
is a bit different to HTML.  The SGML specification defines a language which has a
structure based around the use of <SGMLTAG>&lt;tags&gt;</SGMLTAG>, just like HTML but it
does not define what those tags are or what they do.  You need a Document Type Definition
which is an implementation of SGML to actually use it - one example is 
<link linkend="DOCBOOK" type="int">DocBook</link>, another is the proposed successor to HTML.
This however isn't enough if you want to translate the SGML into a more usable format
such as HTML or RTF.  As SGML is layout independent you require a 
<link linkend="STYLESHEET" type="int">stylesheet</link> that says how to actually lay out your document on the
page.
		</para>
	</preface>
	<chapter id="PROGRAMS">
		<title>Required programs</title>
		<sect1><title>Introduction</title>
			<para>
				To author a SGML document and compile it into RTF or HTML you need
				<itemizedlist>
					<listitem>
						<para>Document Type Definition</para>
					</listitem>
					<listitem>
						<para>SGML parser</para>
					</listitem>
					<listitem>
						<para>and Style Sheet</para>
					</listitem>
				</itemizedlist>
				The ones I used are, respectively, DocBook 3.0, Jade 1.1.1 and Norman
				Walsh's DocBook Style sheets.
			</para>
		</sect1>
		<sect1 id="DOCBOOK">
			<title>DocBook 3.0</title>
			<para>
				DocBook is supplied by the Davenport group and is available from
				<ulink URL="http://www.ora.com/davenport/" TYPE="external">their web site.</ulink>
			</para>
		</sect1>
		<sect1 id="JADE">
			<title>Jade 1.1.1</title>
			<para>
				Jade is a SGML parser written by James Clark and is available from
				<ulink URL="http://www.jclark.com/jade" TYPE="external">his web site.</ulink>
				Note that binarys are available for Win95 and NT.
			</para>
		</sect1>
		<sect1 id="STYLESHEET">
			<title>DocBook Style Sheets</title>
			<para>
				Norman Walsh maintains a good set of style sheets centered around RTF and
				HTML for the DocBook DTD.  Search for <ulink url="http://ftpsearch.ntnu.no/cgi-bin/search?query=db.zip" type="ext">db.zip</ulink> using
				<ulink url="http://ftpsearch.ntnu.no/" type="ext">your favourite search engine</ulink>.  Use the instructions in the <literal>doc</literal>
				directory to install and test jade and DocBook.
			</para>
		</sect1>
	</chapter>
	<chapter id="TEMPLATE">
		<title>A simple template</title>
		<para>
			SGML is significantly stricter than HTML.  Most sections require
			other sections to be defined inside them to make them complete.  For example,
			a chapter <SGMLTAG>&lt;chapter&gt;</SGMLTAG> requires a <SGMLTAG>&lt;title&gt;</SGMLTAG>
			and something inside it like a <SGMLTAG>&lt;para&gt;</SGMLTAG> (paragraph.  And, of
			course, the top level section <SGMLTAG>&lt;book&gt;</SGMLTAG> (like <SGMLTAG>&lt;body&gt;</SGMLTAG>
			in HTML) requires a <SGMLTAG>&lt;bookinfo&gt;</SGMLTAG> and at least one <SGMLTAG>&lt;chapter&gt;</SGMLTAG> entry.
			The minimum required is:
			<synopsis>
&lt;!DOCTYPE Book PUBLIC "-//Davenport//DTD DocBook V3.0//EN"&gt;
&lt;book&gt;
	&lt;title&gt;
		Your title
	&lt;/title&gt;
	&lt;bookinfo&gt;
		&lt;bookbiblio&gt;
			&lt;authorgroup&gt;
				&lt;author&gt;&lt;firstname&gt;Michael&lt;/firstname&gt;&lt;surname&gt;Hope&lt;/surname&gt;&lt;/author&gt;
			&lt;/authorgroup&gt;
			&lt;productname&gt;
				Product that this relates to
			&lt;/productname&gt;
			&lt;pubdate&gt;July 3rd 1998&lt;/pubdate&gt;
			&lt;copyright&gt;
				&lt;year&gt;1998&lt;/year&gt;
				&lt;holder&gt;Michael Hope&lt;/holder&gt;
				&lt;/copyright&gt;
			&lt;abstract&gt;
				&lt;para&gt;
					Text to appear in the abstract
				&lt;/para&gt;
			&lt;/abstract&gt;
		&lt;/bookbiblio&gt;
	&lt;/bookinfo&gt;
	&lt;toc&gt;&lt;/toc&gt;
	&lt;preface id="PREFACE"&gt;
		&lt;title&gt;Preface&lt;/title&gt;
		&lt;para&gt;
			Preface with a reference &lt;xref linkend="STYLESHEET"&gt;
		&lt;/para&gt;
	&lt;/preface&gt;
	&lt;chapter id="PROGRAMS"&gt;
		&lt;title&gt;First chapter&lt;/title&gt;
		&lt;sect1&gt;
			&lt;title&gt;First section in chapter 1&lt;/title&gt;
			&lt;para&gt;
				This paragraph contains a list
				&lt;itemizedlist&gt;
					&lt;listitem&gt;
						&lt;para&gt;Item 1&lt;/para&gt;
					&lt;/listitem&gt;
					&lt;listitem&gt;
						&lt;para&gt;Item 2&lt;/para&gt;
					&lt;/listitem&gt;
				&lt;/itemizedlist&gt;
			&lt;/para&gt;
		&lt;/sect1&gt;
		&lt;sect1 id="DOCBOOK"&gt;
			&lt;title&gt;Second section in chapter one&lt;/title&gt;
			&lt;para&gt;
				An external HTTP url &lt;ulink URL="http://www.ora.com/davenport/" TYPE="external"&gt;and its name&lt;/ulink&gt;
			&lt;/para&gt;
		&lt;/sect1&gt;
	&lt;/chapter&gt;
	&lt;chapter id="TEMPLATE"&gt;
		&lt;title&gt;The second chapter&lt;/title&gt;
		&lt;para&gt;
			A synopsis copies the text with line breaks directly out - good for listings
			&lt;synopsis&gt;
Blah
			&lt;/synopsis&gt;
		&lt;/para&gt;
	&lt;/chapter&gt;
&lt;/book&gt;
			</synopsis>
			A copy of the template is available <ulink URL="template.sgml" type="external">here</ULINK>
		</para>
	</chapter>
	<chapter id="TAGS">
		<title>Commonly used tags and their HTML equivalents</title>
		<para>
			I'm no HTML or SGML wizard so this is by no means an exhaustive list.  It is
			however enough to get you started.
		</para>
		<sect1 id="book-tag">
			<title>Beginning a document - the <SGMLTAG>&lt;book&gt;</SGMLTAG> tag</title>
			<para>
				This is very similar to the <SGMLTAG>&lt;body&gt;</SGMLTAG> tag in HTML as it
				starts the proper document.  Unlike HTML however you are required
				to add a <SGMLTAG>&lt;bookinfo&gt;</SGMLTAG> which in itself requires a
				<SGMLTAG>&lt;bookbiblio&gt;</SGMLTAG>, <SGMLTAG>&lt;abstract&gt;</SGMLTAG>.  See the
				<link linkend="TEMPLATE" type="internal">template</link> for more info.
			</para>
		</sect1>
		<sect1 id="p-tag">
			<title>Paragraphs</title>
			<para>
				Very similar to HTML.  Use <SGMLTAG>&lt;para&gt;</SGMLTAG> to start a paragraph.  Don't forget to
				close it using <SGMLTAG>&lt;/para&gt;</SGMLTAG>.  Break paragraphs using
				<SGMLTAG>&lt;SBR&gt;</SGMLTAG>.
			</para>
		</sect1>
		<sect1 id="sections-tag">
			<title>Sections</title>
			<para>
				Unlike HTML which is unstructured with the headings being a kind of afterthought,
				DocBook documents are rigidly structured into books, chapters and sections.
				This allows items like a table of contents and chapter contents to be
				generated quite easily and helps in dividing the SGML
				document into multiple HTML pages.  Note that nothing should appear
				between sections, but can appear between a start of
				chapter tag <SGMLTAG>&lt;chapter&gt;</SGMLTAG> and the first
				section.  The sections tags are called <SGMLTAG>&lt;sect1&gt;</SGMLTAG>
				through to <SGMLTAG>&lt;sect4&gt;</SGMLTAG>..perhaps further :).
				Each <SGMLTAG>&lt;sect*&gt;</SGMLTAG> must be followed by a
				<SGMLTAG>&lt;title&gt;</SGMLTAG><SGMLTAG>&lt;/title&gt;</SGMLTAG> which
				contains the title for the section.  You must do the same
				for a chapter.
			</para>
		</sect1>
		<sect1 id="links">
			<title>Links</title>
			<para>
				Links are handled slightly differently in the DocBook DTD.
				A label is defined within a document by adding an extra
				field called id into the sect or chapter tag.  For example
				the tag <SGMLTAG>&lt;sect1 id="first-section&gt;</SGMLTAG>
				defines a label called 'first-section'.  Note that
				you can't use underscores in a label.
				To link to that label you have a couple of choices.  One
				is a cross reference like <SGMLTAG>&lt;xref linkend="first-section"&gt;</SGMLTAG>
				will create a link reading "the section called (whatever was specified in the title)
				Or you can create a link where you can specify the text by using
				<SGMLTAG>&lt;link linkend="first-section" type="int"&gt;</SGMLTAG>the first section<SGMLTAG>&lt;/link&gt;</SGMLTAG>.
				to create a link to the first section with the description
				"the first section".  Note that the type is arbitrary - I'm
				not even sure if it's required.
				External links can be made using something like
				<SGMLTAG>&lt;ulink url="http://www.nowhere.com/fish/" type="ext"&gt;</SGMLTAG>Go to nowhere.com<SGMLTAG>&lt;/ulink&gt;</SGMLTAG>
			</para>
		</sect1>
		<sect1 id="lists-tag">
			<title>Lists</title>
			<para>
				I only know about <SGMLTAG>&lt;itemizedlist&gt;</SGMLTAG>.  It's
				very similar to a HTML list with the <SGMLTAG>&lt;li&gt;</SGMLTAG>
				being replaced with <SGMLTAG>&lt;listitem&gt;</SGMLTAG>.  For
				example the itemized list back in <xref linkend="PROGRAMS"> is
				<synopsis>
&lt;itemizedlist&gt;
	&lt;listitem&gt;
		&lt;para&gt;Document Type Definition&lt;/para&gt;
	&lt;/listitem&gt;
	&lt;listitem&gt;
		&lt;para&gt;SGML parser&lt;/para&gt;
	&lt;/listitem&gt;
	&lt;listitem&gt;
		&lt;para&gt;and Style Sheet&lt;/para&gt;
	&lt;/listitem&gt;
&lt;/itemizedlist&gt;
				</synopsis>
			</para>
		</sect1>
		<sect1 id="special-tag">
			<title>Formatting tags</title>
			<para>
				The ones I know of are <emphasis>emphasis</emphasis>,
				<literal>literal</literal> and synopsis.  <SGMLTAG>&lt;synopsis&gt;</SGMLTAG>
				will copy the text including line breaks verbatim in the
				courier font.  The listitem example <link linkend="lists-tag" type="int">above</link>
				is in synopsis style.
			</para>
		</sect1>
	</chapter>
	<chapter id="compiling-examples">
		<title>Compiling your SGML document and some examples</title>
		<sect1 id="compiling">
			<title>Compiling</title>
			<para>
				See the installation instructions in <link linkend="STYLESHEET">Norm Walsh's style sheets</link>
			for installing Jade and DocBook and testing your installations.
			Once all three programs are installed and tested, you can compile
			your brand spanking new SGML file into RTF, LaTeX or HTML using
			Jade.  For compiling into HTML I use
				<synopsis>
jade -t sgml -d g:\sgml\db\html\docbook.dsl file.sgml
				</synopsis>
				For compiling into RTF format I use
				<synopsis>
jade -t rtf -d g:\sgml\db\print\docbook.dsl file.sgml
				</synopsis>
				Note that for some reason the bookmarks in all of my documents dont seem to work.  I dont know why.
			</para>
			<para>
				Using some external tools you can also generate TeX, Postscript and PDF format.  Unfortunatly
				I dont have links for most of these programs as they came pre built with Debian Linux.
			<para>
				To turn the sgml into TeX, use
				<synopsis>
jade -t rtf -d g:\sgml\gb\print\docbook.dsl file.sgml
				</synopsis>
				To actually print this file you will need the extra TeX package mentioned on the Jade pages.
				This allows you to produce a Postscript file using dvips:
				<synopsis>
latex file.tex
dvips -o file.ps file.dvi
				</synopsis>
				Then using Aladin Ghostscript you can turn the Postscript file into a PDF using
				<synopsis>
gs -dQUIET -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=file.pdf file.ps -c quit
				</synopsis>
				I use a makefile to produce all of the above formats automatically.  It looks like:
				<synopsis>
DB = /home/michaelh/sgml/db
DB_PRINT = $(DB)/print/docbook.dsl
DB_HTML = $(DB)/html/docbook.dsl
TEX_FMT = -fmt jadetex

SG=intro-to-sgml

# Note:  Done in this order so that the .gz's work
all: html/book01.htm $(SG).rtf $(SG).pdf $(SG).ps.gz $(SG).tex.gz

clean:
	rm -f $(SG).rtf $(SG).pdf $(SG).ps.gz $(SG).tex.gz $(SG).aux $(SG).log
	rm -rf html

%.gz: %
	gzip -9 $&lt;

%.rtf: %.sgml
	jade -t rtf -d $(DB_PRINT) $&lt;

html/book01.htm: $(SG).sgml
	mkdir -p html; 
	(cd html; jade -t sgml -d $(DB_HTML) ../$&lt;)

%.tex: %.sgml
	jade -t tex -d $(DB_PRINT) $&lt;

# Tested with TeX, Version 3.14159 (Web2C 7.2)
%.dvi: %.tex
	latex $(TEX_FMT) $&lt;

# Tested with dvips(k) 5.78
%.ps: %.dvi
	dvips -o $@ $&lt;

# Tested with Aladdin Ghostscript 5.10 (1997-11-23)
%.pdf: %.ps
	gs -dQUIET -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=$@ $&lt; -c quit
				</synopsis>				
				And that's it!
			</para>
		</sect1>
		<sect1>
			<title>Examples</title>
			<para>
				Strangely enough this introduction was itself written in DocBook SGML :)
				Some examples of SGML are:
				<itemizedlist>
					<listitem>
						<para>
							<ulink url="../intro-to-sgml.sgml" type="ext">This document</ulink>
						</para>
					</listitem>
					<listitem>
						<para>
							<ulink url="../../libs/libs.sgml" type="ext">Documentation for some parts of GBDK.</ulink>
						</para>
					</listitem>
					<listitem>
						<para>
							<ulink url="http://www.ora.com/davenport/samples/dec1/techovr.sgml" type="ext">Digital UNIX Technical Overview at Davenports site</ulink>
							<ulink url="techovr.sgml" type="ext">(local copy)</ulink>
						</para>
					</listitem>
					<listitem>
						<para>
							The documentation with <link linkend="STYLESHEET" type="int">Norman Walsh's Style sheets</link>
						</para>
					</listitem>
				</itemizedlist>
			</para>
		</sect1>
	</chapter>
</book>
