]>
In many cases, the value of a property will be a simple value, such as `red', `20', or `true'. But sometimes the value must be computed in some way, based on other properties or SGML attributes.
The style language should therefore allow the value to be specified with an expression, consisting of constants, variables, operators, and perhaps some special functions. The values themselves can be of several types, depending on the property.
Dimensionless number
Dimensioned number (cm, mm, inch, point, pixel, pica, em, char?, day, hour, minute, s)
Boolean
String
Symbol
Color (3-tuple?)
Date & time
This is a list of the variables that can be used in an expression:
Attributes: the value of an attribute of the current SGML element.
Meta-variables: information about the document or the viewer, such as:
the age of the document
its size
its creation date
the size of the viewer window
the number of available colors
anchor visited yes/no
in-line images enabled yes/no
Counters: a counter for the number of children (of a certain type) in order to provide numbered labels. Extra counters (or general variables?) may be needed to transfer counters from one element to another.
Inherited property values: the value of a property as it is in the current element's parent.
Operations on values include the following:
Arithemetic: + - * / mod max min interpolate
Boolean: and or xor
Comparison: = <> < > <= >= regexp-match
String: concatenate substring
Conditional: if... then... else...
`Interpolate' is a function of three arguments. It may be useful in situations like this (notation borrowed from Metafont): (AGE/7days)[white, yellow], which means: white + (AGE/7days)(yellow - white)
Operations can be written in a mixture of the usual infix notation and functional notation: 7 - 2 * max(4, 3), or in S-expressions: (- 7 (* 2 (max 4 3))), or in a pure functional notation: sub(7, prod(2, max(4, 3))). The mixture is easiest to read.
Attributes must be distinguished from symbols with the help of punctuation. Possibilities include: !HREF!, ${HREF}, $(HREF), $HREF, !HREF, (attr "HREF"), (attr 'HREF), attr(HREF), attr("HREF").
Meta variables can be written with similar punctuation, or they can be written without any puntuation, taking up a part of the name space for symbols.
Counters can be numbered (if there are more than 2), or given symbolic names (counter, extracounter).
Inherited property values can be distinguished from attributes and meta-variables with yet other punctuation.
(Back) to style sheet overview
Bert Bos, 11 May 1995