|
Subject: Re: Recursive elements in DSSSL From: Brandon Ibach <bibach@xxxxxxxxxxxxxx> Date: Tue, 7 Mar 2000 16:41:51 -0600 |
Quoting Stephane Bortzmeyer <bortzmeyer@xxxxxxxxxx>: > On Mon, Mar 06, 2000 at 03:31:38PM -0600, Brandon Ibach wrote: > > The value of 'n' should be the node (element) whose "section depth" > > you want to calculate. > > I must confess that I wasn't able to program something with these > indications (and "ancestors" do not exist in jade 1.2). Any actual > complete code? > Here ya go... -Brandon :)
<!doctype section [
<!element section - - (section|#PCDATA)*>
]>
<section>
<section>
<section></section>
</section>
<section>
<section>
<section></section>
</section>
</section>
</section>
<!doctype style-sheet PUBLIC "-//James Clark//DTD DSSSL Style Sheet//EN">
<style-specification id=section>
(define debug
(external-procedure "UNREGISTERED::James Clark//Procedure::debug"))
(declare-flow-object-class element
"UNREGISTERED::James Clark//Flow Object Class::element")
(declare-flow-object-class formatting-instruction
"UNREGISTERED::James Clark//Flow Object Class::formatting-instruction")
(declare-characteristic preserve-sdata?
"UNREGISTERED::James Clark//Characteristic::preserve-sdata?" #f)
(define (ancestors nl) (node-list-map (lambda (snl)
(let loop ((cur (parent snl)) (result (empty-node-list)))
(if (node-list-empty? cur) result
(loop (parent cur) (node-list cur result))))) nl))
; These functions are here only for the code that inserts
; newlines to compensate for the parser stripping them out
(define (node-list-last nl) (let loop ((n nl) (r (empty-node-list)))
(if (node-list-empty? n) r (loop (node-list-rest n) (node-list-first n)))))
(define (child-class nl proc) (let ((c (children nl)))
(and (not (node-list-empty? c)) (node-property 'classnm (proc c)))))
(define (first-class nl) (child-class nl node-list-first))
(define (last-class nl) (child-class nl node-list-last))
(root (sosofo-append (process-children)
(make formatting-instruction data: "\U-000D;\U-000A;")))
(element section (let ((n (current-node)))
(make element
attributes: (list (list "depth" (number->string (node-list-length
(select-elements (ancestors n) (gi n))))))
; This (and the one after process-children) re-inserts newlines
(if (equal? (first-class n) 'data-char)
(make formatting-instruction data: "\U-000D;\U-000A;") (empty-sosofo))
(process-children)
(if (not (equal? (last-class n) 'element)) (empty-sosofo)
(make formatting-instruction data: "\U-000D;\U-000A;")))))
</style-specification>
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: Recursive elements in DSSSL, Stephane Bortzmeyer | Thread | Re: Recursive elements in DSSSL, Stephane Bortzmeyer |
| Re: Recursive elements in DSSSL, Stephane Bortzmeyer | Date | [ANNOUNCE] OpenJade 1.3 binaries fo, Alexander Sieb |
| Month |