Re: Issues with literate programming DSSSL Script

Subject: Re: Issues with literate programming DSSSL Script
From: Brandon Ibach <bibach@xxxxxxxxxxxxxx>
Date: Tue, 21 Dec 1999 18:23:39 -0600
Quoting Wroth, Mark <MARK.WROTH@xxxxxxxxxxx>:
> I think you are both getting at the same idea, which I understand to be to
> process the entire node containing the code as a formatting instruction in
> order to disable the parser's attempts to deal with syntactically
> significant punctuation.
> 	Unfortunately, I apparently did not specify the problem well enough.
> Some of the contents of the node are SGML markup (specifically pointers to
> other code scraps which are to be inserted in the output code block).  So an
> example might be 
> <scrap id="scrap1">
> <title>Outside Loop</title>
> While (a < max_a)
> 	<scrapref id="scrap2">
> end
> </scrap>
> [...]
> So I can't just treat the contents of a code scrap as unparsed CDATA; there
> are elements (and potentially entities) which must be parsed.
   Ok... new problem. :)  The solution I gave, when applied to this
situation, would essentially just ignore the <scrapref>, thus not
including the other scrap properly.
   Keep in mind that the whole document is, essentially, parsed before
DSSSL processing begins.  So, just because you "skip" a section of the
document in your DSSSL script doesn't mean that it won't get parsed.
   Off the top of my head, the best solution would be to sift through
the children of each scrap, generating a list of data chunks and
nodes, then outputting the data chunks as formatting-instructions, and
processing the nodes with process-node-list, thus allowing the normal
rules to take care of them.  Something like this should work:

(define breakup (lambda (#!optional (nl (children (current-node))))
  (let loop ((n nl) (s "") (r '()))
    (if (node-list-empty? n) 
        (if (< 0 (string-length s)) (append r (list s)) r)
        (let* ((cn (node-list-first n)) (c (node-property 'class-name cn)))
          (loop (node-list-rest n)
                (if (not (equal? 'data-char c)) ""
                    (string-append s (string (node-property 'char cn))))
                (if (equal? 'data-char c) r
                    (append r (if (< 0 (string-length s)) (list s) '())
                            (list cn)))))))))

(element scrap
  (let loop ((c (breakup)) (r (empty-sosofo)))
    (if (null? c) r (loop (cdr c) (sosofo-append r
          (if (node-list? (car c)) (process-node-list (car c))
              (make formatting-instruction data: (car c))))))))

   Hope this makes sense (and works). :)

-Brandon :)

 DSSSList info and archive:

Current Thread