Re: Processing fot

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
  • Processing fot
    • Charlie & Barbara Bozeman - from mail1.ability.netby web4-1.ability.net (8.8.5/8.6.12) with ESMTP id KAA20188Sat, 20 Jun 1998 10:16:21 -0400 (EDT)
      • Graydon Hoare - from mail1.ability.netby web4-1.ability.net (8.8.5/8.6.12) with ESMTP id MAA05396Mon, 22 Jun 1998 12:24:27 -0400 (EDT) <=
        • Charlie & Barbara Bozeman - from mail1.ability.netby web4-1.ability.net (8.8.5/8.6.12) with ESMTP id VAA02260Mon, 22 Jun 1998 21:34:39 -0400 (EDT)
      • Daniel Speck - from mail1.ability.netby web4-1.ability.net (8.8.5/8.6.12) with ESMTP id NAA07056Mon, 22 Jun 1998 13:31:01 -0400 (EDT)
        • Charlie & Barbara Bozeman - from mail1.ability.netby web4-1.ability.net (8.8.5/8.6.12) with ESMTP id WAA08740Mon, 22 Jun 1998 22:21:10 -0400 (EDT)
          • Daniel Speck - from mail1.ability.netby web4-1.ability.net (8.8.5/8.6.12) with ESMTP id JAA10655Tue, 23 Jun 1998 09:44:52 -0400 (EDT)