declare-initial-value

Subject: declare-initial-value
From: Paul Prescod <papresco@xxxxxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 04 Jul 1997 11:59:35 -0400
It is common in our contemporary DSSSL style sheets to do something like
this:

       top-margin: *top-margin*
       bottom-margin: *bottom-margin*
       left-margin: *left-right-margin*
       right-margin: *left-right-margin*
       header-margin: *header-margin*
       footer-margin: *footer-margin*
       page-width: *page-width*
       page-height: *page-height*

Where these are defined above. I would (mildly) prefer if we used the
DSSSL feature that allows inherited characteristics to be declared like
this:

(declare-initial-value writing-mode 'left-to-right)
(declare-initial-value font-size 12pt)
(declare-initial-value line-spacing 14pt)
(declare-initial-value font-family "iso-serif")

I think that if a DSSSL feature exists to do what we want then there are
probably good reasons to stick to it that will become clear later. I've
stumbled across such a reason. Let's say I want to override the
definition for an inherited characteristic but I don't want to touch a
stylesheet. I can do so in a "driver" stylesheet that uses the "modules"
mechanism to include the "read-only" stylesheet. My initial values take
precedence over the stylesheet author's. (** I think **)

But if the stylesheet author has used some arbitrarily named variable to
hold the initial value then I must go look it up. In the "big picture"
this means that a human being must scan the stylesheet before the value
can be changed. Whereas with (declare-initial-value ...) I could write a
GUI that allows end-users to override (default) page margins and
(default) font-sizes without reading the stylesheet's text at allo. Or
else I could just retarget my "driver file" from stylesheet to
stylesheet to adjust the page size or (default) font size (for
instance).

The nice part is that (declare-initial-value foo ...) is almost a
drop-in replacement for (define *foo* ...) in most stylesheets. It
doesn't even break the nice features authors have set up for customizing
several parameters at once (e.g. (define paper-type A4)). In the example
following the style-sheet author has a variable that allows stylesheet
users to choose from "wired-style" vs. other styles. The user chooses to
use "wired-style" BUT also change the font-size to something other than
what the hard-coded "wired-style" allows.


<!doctype style-sheet PUBLIC "-//James Clark//DTD DSSSL Style
Sheet//EN"[
<!entity main.stylesheet SYSTEM "main.dsl" NDATA DSSSL>
]>

<!-- This is the "driver" that is called by Jade -->
<style-specification use="main.dsl">
<style-specification-body>

(declare-initial-value font-size 25pt)
(define *style* 'wired-style)
  ;; by combining the authors definition of wired-style
  ;; with my font-size I've made "wired-style for sight-impaired people"

</style-specification>


<!-- This is the "main" read-only driver that would typically reside
     in a separate file -->
<style-specification id="main.dsl">
(define debug
  (external-procedure "UNREGISTERED::James Clark//Procedure::debug"))

;; This is ignored because the declaration above overrides it.
(declare-initial-value font-size 
	(case *style* 
	   (('wired-style)  9pt)
	   (('nyt-style) 12pt)
	   (('washpost-style) 14pt)))
	
;; This is not ignored because there is no declaration above.
(declare-initial-value writing-mode 
	(case *style* 
	   (('wired-style) 'right-to-left)
	   (else 'left-to-right)))

(element style-specification
    (make simple-page-sequence
	writing-mode: (debug (inherited-writing-mode))
	font-size: (debug (inherited-font-size))))

</style-specification>

If there is some way that this text can be of value to the DSSSL
documentation project then please say so. It seems like it belongs in a
"tips and tricks" section.

 Paul Presscod


 DSSSList info and archive:  http://www.mulberrytech.com/dsssl/dssslist


Current Thread