[Previous] [Contents] [Next]


Flow Object Tree


The DSSSL style sheet consists of a series of so-called flow object specifications. Each of these specifications (technically one of these specifications is called a sosofo-a specification of a sequence of flow objects). The following rule doesn't actually create a flow object; it just specifies how one is to be made using a make statement:

(make paragraph font-size: 12pt )

Put very simply, jade takes the sosofos and uses them to create flow objects. You can think of the sosofo as being the template and the flow objects as being the result of applying the template to the source document.

Taking all the sosofos together, jade creates what is called a flow object tree (fot).

When jade (or any other DSSSL engine) processes a document, it creates an abstract representation of the result of merging the formatting specification and the source document. This representation is called the flow object tree and the nodes of this tree are the flow objects.

Figure 19.6 illustrates a typical flow tree that might be produced by jade.

The formatted output, the results that will be printed or displayed, are created by formatting this tree of flow objects.

If you understand the concept of the flow object tree, you understand enough to grasp the essentials of how DSSSL works. If you think of the root of the document tree starting at the root element, you can select an element in that tree and process it in one way to apply one particular formatting specification. Later in the style sheet you can select that element again and apply a different formatting specification. These trees are then merged into the flow output tree, which can include both variations.
Figure 19.6 Processing a document.

Is this explanation too abstract? Let me offer a practical example.

What is a table of contents? You process the document starting at the root element and pick out the headings. You output a paragraph that says something like "Table of Contents" and then you output each heading formatted in a particular way, probably with the page number appended (you could even make this page number an active link). If all you want to do is extract the table of contents, you have already finished. This isn't much use if you want to format the real contents of the document, though. Having processed the whole of the document to create the table of contents, you now have to go back to the root element (or maybe you'd go to the first second level heading and skip what might be the title) and process the whole document to create the actual output.

The merging process that creates the flow output tree allows you to process the source document as many times as you like, in as many ways as you like, so that, from a raw XML document, you can add tables of contents, tables of figures, indexes, glossaries, lists of references, and so on. This is what makes the power and the potential of DSSSL so much more exciting than a simple style language. DSSSL is a processing language; a transformation language and a style language combined. In fact, DSSSL remains a full programming language; you can include procedures, functions, macros, conditional processing, process flow control, expressions-everything that you might expect from a proper programming language. This, however, goes far beyond the scope of this chapter-even beyond the scope of this book, and so we'll come back down to practicalities and return to the mechanics of style sheets.

[Previous] [Contents] [Next]