Re: Processing fot

Subject: Re: Processing fot
From: Charlie & Barbara Bozeman <cbozeman@xxxxxxxxxx>
Date: Tue, 23 Jun 1998 02:17:00 +0000
Daniel Speck wrote:
> 
> Charlie Bozeman wrote:
> 
> > Question: Is it possible to generate info from a document once and then
> > reference the info as you process the document?
> >
> 
> In general, no, not using standard DSSSL which is side-effect free.

I was hoping there is some scheme trick that would work, my scheme 
knowledge is weak.

> 
> > When I process a flow-object-tree (from jade of course) I only want to
> > process the "a" elements that are referenced by "page-number" elements
> > (with the ref attribute) within the fot. Currently I do this by
> > selecting
> > all the "page-number" elements in the document and check if their "ref"
> > attribute matches my current "a" element. As you might imagine, this is
> > very time consuming.
> 
> I'm not sure what you are trying to do. It would be helpful to see the DTD,
> a small sample instance and a description of the end result you are trying
> to achieve (I don't know what the <a> or the <page-number> elements
> represent). This sort of processing is often done using modes in DSSSL. If
> you are using ID/IDREF to link elements you can use a mode together with
> (process-element-with-id ...) to process a referenced element.

I am playing around with converting the flow-object-tree which jade
produces, to groff. In order to build a table-of-contents I need to 
forward reference page numbers. My solution is to build an auxiliary
file with the page number of the "a" elements and input the file
in the main document. This is obviously a two-pass process and there
may be some better way of doing this, but my knowledge of 'roff is
worse than my knowledge of scheme.

The dtd (fot.dtd) comes with the jade source; here is a fragment of what
I am doing:

(define (check-page-number-ref name)
  (let  ((p-num (select-elements (descendants (sgml-root-element))
                                 "page-number")))
    (let loop ((nl p-num))
      (if (node-list-empty? nl)
          #f
          (let* ((snl (node-list-first nl))
                 (ref (attribute-string "ref" snl))
                 (rest (node-list-rest nl)))
            (if (equal? ref name)
                #t
                (loop rest)))))))


(element a
  (let  ((name (attribute-string (normalize "name"))))
    (make sequence
      (if (check-page-number-ref name)
          (write-string-RE 
            (string-append ".sy echo .ds anch@" name " \\n%
>>groff.aux"))
          (empty-sosofo)))))

(element page-number
  (let  ((ref (attribute-string (normalize "ref"))))
    (make sequence
      (if ref
          (write-string (string-append "\\*[anch@" ref "]"))
          (write-string "\\\\n%")))))


Charlie B.


 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)
      • <Possible follow-ups>
      • Reynolds, Gregg - from mail1.ability.netby web4-1.ability.net (8.8.5/8.6.12) with ESMTP id NAA06542Mon, 22 Jun 1998 13:07:00 -0400 (EDT)
        • Charlie & Barbara Bozeman - from mail1.ability.netby web4-1.ability.net (8.8.5/8.6.12) with ESMTP id VAA05208Mon, 22 Jun 1998 21:49:40 -0400 (EDT)