About SGMLISUG PubsBookstoreChaptersDeveloping SGMLJoin ISUG

A Gentle Introduction to DSSSL

Dan Speck, Research Engineer, Advanced Publishing Methods Lab, Thomson Technology Services Group,Rockville, Maryland, USA. Email: dspeck@thomtech.com; WWW: http://www.thomtech.com/~dspeck.

Contents


Preface

I started learning DSSSL (Document Style Semantics and Specification Language, ISO 0179:1996) about nine months ago. DSSSL has been an international standard since February of 1996 and the only currently available DSSSL processor, James Clark's Jade, has been publicly available since about November 1996.

The time is right for commercial publishers to begin examining DSSSL as a means of creating their products. Although there is still quite a lot of work to be done on the DSSSL implementation side, the currently available and soon to be available tools look very promising.

A Quick Example

A DSSSL style specification allows you to associate an output style with an input document. Consider the following small DTD:

<!element book - o (title, chapter+)>

<!element title - o (#PCDATA)>

<!element chapter - o (title, p+)>

<!element p - o (#PCDATA|emph)*>

<!element emph - o (#PCDATA)>

Here is a DSSSL style specification that will format documents conforming to the above DTD:

<!DOCTYPE style-sheet PUBLIC "-//James

Clark//DTD DSSSL Style Sheet//EN">

(declare-initial-value font-family-name

"Times Roman")

(declare-initial-value font-size 10pt)

(declare-initial-value min-leading 0pt)

(element book

(make simple-page-sequene

left-margin: 1.5in

right-margin: 1.5in

top-margin: 1in

bottom-margin: 1in

(process-children))

(element (book title)

(make paragraph

space-before: 3in

font-size: 36pt

font-weight: 'bold

quadding: 'center

(process-children)))

(element chapter

(process-children))

(element (chapter title)

(make paragraph

break-before: 'page

keep-with-next?: #t

font-size: 18pt

font-weight: 'bold

space-before: 1in

space-after: .5in

quadding: 'start

(process-children)))

(element p

(make paragraph

first-line-start-indent:

(if (= (child-number) 1)

0pt

10pt)

(process-children)))

(element emph

(make sequence

font-posture: 'italic

(process-children))

Let's take a closer look at this example. The first line of the specification reads '<!DOCTYPE style-sheet … >'.. DSSSL specifications are SGML documents that conform to something called the DSSSL document architecture. The document type declaration refers to a DTD that conforms to the architecture and which was provided by James Clark with his Jade DSSSL style engine. In practice all that is needed in the style specification is an appropriate document type declaration; no other SGML constructs are required in the body of the specification. You must be careful, however, to avoid using SGML markup (or to appropriately quote such markup) in the body of a DSSSL specification so that it is not mistakenly interpreted as SGML markup when the specification is read by the DSSSL processor.

The rest of the specification consists of declarations written in the DSSSL expression language.

The first three lines following the doctype declaration establish default values to be used for the font family, font size, and leading. The rest of the specification consists of element construction rules that tell the DSSSL style engine how to process the named elements.

The first element construction rule, (element book …), says that whenever any element of type book is encountered in the input SGML document the style engine should construct a simple-page-sequence. The keywords left-margin:, right-margin:, top-margin: and bottom-margin: specify characteristics of the simple-page-sequence being constructed. The (process-children) says that once the simple-page-sequence has been created, processing should continue by recursively processing each of the children of the current element-in the case of book its title and chapters.

The value of a characteristic can be specified based on the context of the element being processed. For example, the element construction rule for p says that whenever a p element is encountered a paragraph should be constructed. A characteristic named first-line-start-indent is specified for the paragraph and its value depends on whether it is the first p element in a sequence of p elements under its parent. If it is the first then first-line-start-indent is set to 0pt, otherwise it is set to 10pt. This has the effect of creating a block-style paragraph following titles or other non-paragraph elements while indenting other paragraphs.

Running Jade

Assuming that the DSSSL specification is stored in a file called book.dsl, the SGML document we wish to process is called mybook.sgml and we have an SGML Open catalog called catalog that contains the mappings for public identifiers in the book DTD, here is a Jade command line that could be used to format the SGML document to produce an RTF document with the appropriate style:

jade -c catalog -d book.dsl -t rtf -o mybook.rtf mybook.sgml

[Next Section]

Contact Robin Cover with corrections and updates, or to submit contributions to the ISUG online document database.

ISUG 
logo
Copyright © 1998 International SGML Users' Group