|
Subject: Numbering sections - erratum From: Richard Light <richard@xxxxxxxxxxxxxxxxx> Date: Tue, 11 Nov 1997 12:39:03 +0000 |
An apology and a request for help ...
When I proferred this suggestion:
<cookbook>
As a possible cookbook contribution, I've just had to deal with the
situation where sections within a document have to be numbered according
to the familiar 'X.X.X' scheme, but only specified element types 'count'
as contributors to this numbering. Also, there can be a glorious
mixture of said element types at each level. Thus (child-number) is no
use, and even counting preceding siblings isn't good enough.
The code I have written uses (node-list-filter), which in turn uses
(node-list-reduce) - these are both printed in the DSSSL standard, but
you need to type them in. This is the core routine:
; preced-count: gives the number of 'significant' (for numbering)
sibling elements prior to node.
; This routine relies on a specific list of element types, which must
include all elements that
; are numbered:
(define (preced-count node)
(node-list-length
(node-list-filter
(lambda (n1)
(case (gi n1)
((countable-elements) #t)
(else #f)
)
)
(preced node)
)
)
)
You need to declare your 'countable elements' as a list of strings:
(define (countable-elements)
(list "XXX" "YYY" "ZZZ" ...)
)
...
</cookbook>
I thought that I had tested the use of a (countable-elements)-type
procedure as a means of specifying the list of GI's, and found it to
work. However, I can't have done, because it doesn't!
You can get around this problem by specifying the list of GI's directly
within the routine:
(define (preced-count node)
(node-list-length
(node-list-filter
(lambda (n1)
(case (gi n1)
(("XXX" "YYY" "ZZZ" ...) #t)
(else #f)
)
)
(preced node)
)
)
)
but this isn't very elegant.
My original idea - of declaring the list of fields as a procedure - is
with hindsight pretty silly anyway. What you want to do is to pass the
list of fields as an argument to the (preced-count) procedure; something
like:
(define (preced-count node gilist)
(node-list-length
(node-list-filter
(lambda (n1)
(case (gi n1)
(gilist #t)
(else #f)
)
)
(preced node)
)
)
)
Can anyone advise how you pass a list of strings as an argument in this
way? Jade complains about the 'gilist' within the (case ...) statement
when I use the syntax above since it is trying to interpret it as a
procedure. However, if I protect it by putting it inside a (list ...)
procedure:
((list gilist #t))
it clearly has the wrong form for a (case ...) datum, and won't match.
Any thoughts?
Richard Light.
DSSSList info and archive: http://www.mulberrytech.com/dsssl/dssslist
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Numbering sections (was Scaling inl, Richard Light | Thread | Re: Numbering sections - erratum, Paul Prescod |
| Re: Jade Headers and Footers, Frank Christoph | Date | Re: Numbering sections - erratum, Paul Prescod |
| Month |