Subject: Re: Processing fot From: Graydon Hoare <graydon@xxxxxxxxxxxxx> Date: Mon, 22 Jun 1998 12:19:10 -0400 (EDT) |
On Sat, 20 Jun 1998, Charlie & Barbara Bozeman wrote: > I wondered if I could build an assoc list of "page-number" elements > that referenced "a" elements once; then checked the assoc list for a > match when I processed each "a" element. This assoc list would have to > be global so this won't work. First of all, if it's a big list, use member, not assoc. Member will dive into C, so it runs real fast. I'm using member to do table-based character code rewriting and it is fast enough. You're right in that you can't really use set! that way. I think you can achieve what you want by controlling the sosofo construction using some kind of named let. No guarantees that it works, mind you.. let me know if this solves the problem. ;; this engages the controlled processor defined below (element root-of-tree (process-fot (current-node))) ;; this should do a controlled pass over your fot ;; processing "a" nodes if their id attribute is in the ref list ;; (see below) and processing all other nodes as it goes. ;; you'll still need to write production rules for each node ;; you want to process, but they should not call (implicitly or ;; explicitly) (process-children) at the end. This does it for you. ;; the reason is that if you return to (process-children) you will ;; lose control over the processing for all child nodes. (define (process-fot fot) (let ((member-list (make-member-list fot))) (let loop ((nodes-to-process fot)) (let* ((the-node (node-list-first nodes-to-process)) (do-this-node (lambda () (make sequence (process-node-list the-node) (loop (children the-node)))))) (if (node-list-empty? the-node) (empty-sosofo) (case (gi the-node) (("a") (if (member (id the-node) member-list) (do-this-node) (empty-sosofo))) (else (do-this-node)))))))) ;; this builds a list of all the unique ref values (define (make-member-list fot) (let ((page-number-elements (select-elements (descendants fot) 'page-number))) (let loop ((member-list '()) (nodes-to-process fot)) (let ((the-node (node-list-first nodes-to-process))) (if (node-list-empty? the-node) member-list ;; all done! (let ((the-ref (attribute-string "ref" the-node))) (loop (if (member the-ref member-list) member-list (cons the-ref member-list)) (node-list-rest nodes-to-process)))))))) DSSSList info and archive: http://www.mulberrytech.com/dsssl/dssslist
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Processing fot, Charlie & Barbara Bo | Thread | Re: Processing fot, Charlie & Barbara Bo |
Re: Paragraph spacing, Tony Graham | Date | Re: Books about DSSSL, Tony Graham |
Month |