[Previous] [Contents] [Next]


Construction Rules


A construction rule consists of a make expression, followed by the name of a flow object class, a list of any of the characteristics and their values that you want to set for the flow object instance, and then some (optional) processing instructions that select particular child elements for processing.

For example,

(root
  (make simple-page-sequence
      (process-children))

This dumps the whole of the document without any particular formatting, whereas the following is quite a different story:

(make paragraph
    space-before:           (if (or (equal? (gi (parent)) "A")
                    (equal? (gi (parent)) "B"))
                    0pt
                    10pt)
    (process-children-trim))

DSSSL's syntax takes some getting used to, so let's dissect this expression bit by bit:

We have an if keyword followed by a test expression:
(or (equal? (gi (parent)) "A")(equal? (gi (parent)) "B"))

If this test expression evaluates to true the value of space-before will be 0pt. If it evaluates to false the value of space-before will be 10pt.
The test expression is an or expression consisting of two test expressions:
(equal? (gi (parent)) "A")

and
(equal? (gi (parent)) "B")
The first test expression is
equal? (gi (parent)) "A"

or in plain English, "is the parent element of this element an A element?"
The second test expression is
equal? (gi (parent)) "B"

or in plain English, "is the parent element of this element a B element?"

So, if the parent of this element is either an A element or a B element, the value of space-before will be 0pt. If it isn't, the space-before value will be 10pt.

As well as using numerical expressions, you can use characters, strings, logical expressions, and even procedures. Expressions in DSSSL can be powerful tools for selecting elements, and you can supplement them by selecting the first element, the last element, and any particular element according to its position in the tree or any of its attributes and attribute values. I won't go into any more detail here, but there are some excellent explanatory documents available on the Web at http://www.mulberrytech.com/dsssl/dsssldoc. In the meantime, I suggest you look at other people's examples and try to learn from them.

[Previous] [Contents] [Next]