RE: (dsssl) Dynamic defines

Subject: RE: (dsssl) Dynamic defines
From: "Nilsson, Peter" <pni@xxxxxxxxx>
Date: Tue, 27 Feb 2001 08:09:55 +0100

> -----Original Message-----
> From: Francis J. Lacoste [mailto:francis.lacoste@xxxxxxxxxx]
> Sent: den 26 februari 2001 18:28
> On Mon, Feb 26, 2001 at 08:45:41AM -0500, Devin Weaver wrote:
> > 
> > I want to (define %show-comments% #t) only if status="draft"
> > The problem is in my custom dsl the current-node has yet to 
> be defined
> > so there is no way for me to get at the attributs of book. 
> and even if
> > I did the root element can change. (Could be article, part, 
> set, etc.)
> > 
> You could try the following :
> (root
>     (let* ((root-node (node-property 'document-element (current-node)
>                                          default: (empty-node-list)))
>            (status (attribute-string "status" root-node))
> 	   (%show-comment (equal? status "draft")))
>       (process-node-list root-node)))
> Normally, this local binding of %show-comment% should override the 
> global one.
This would bind a value to %show-comment depending on the attribute, but
that binding is only available in the let* expression. Remember that Scheme
(which DSSSL is built upon) is lexically scoped, something that's different
in other dialects of Lisp. I think you have to accept the fact that you
can't define a top-level variable to depend on something in the grove being
processed. However, you can of course:
- define a top-level to depend on something in a particular grove (using the
sgml-parse procedure).
- if you are using docbook, override the construction rule for the comment
element and do whatever you want. See also the next-match procedure. (Of
course, this is not restricted to docbook, but I think that was what you
mentioned earlier.)
- Define a function that returns what you need (see Russell O'Connor's
mail). This may not be feasable if you are customizing the docbook
stylesheets and it depends on the variable being a boolean, not a function.

Personally, I would redefine the construction rule for the comment element.

//Peter Nilsson

 DSSSList info and archive:

Current Thread