|
Subject: (dsssl) Re: If no P children? From: Tim McDaniel <tmcd@xxxxxxxxx> Date: Sun, 16 Mar 2003 03:46:39 -0600 (CST) |
(By the way, I apologize if I use incorrect terminology. I know
little about XML and DSSSL.)
On Sun, 16 Mar 2003, Tim McDaniel <tmcd@xxxxxxxxx> wrote:
> (make element gi: "dd"
> (if ANY DESCENDANT OF THIS ITEM IS A <P>
> (process-matching-children 'discussion
> (literal " ")
> ) ;; make element dd
I found a way.
I used "our-" as a prefix just to avoid namespace collisions. Perhaps
a better name for "our-has?" is "node-list-some-recursive?". Since
"our-is-p?" was used in just one place, I could have made it a lambda
expression, but I don't usually get that LISPy. I could have
generalized it more, by writing a "node-list-reduce-recursive"
function and then use that for this.
(define (our-is-p? node) (match-element? '(p) node))
;; our-has?: #t if proc is true for any member of nl or its
;; descendents, #f otherwise.
;; It does a depth-first search, applying proc to each element it gets
;; to. It returns #t as soon as proc returns a true value for something.
(define (our-has? proc nl)
(if (node-list-empty? nl)
#f
(if (proc (node-list-first nl))
#t
(if (our-has? proc (children (node-list-first nl)))
#t
(our-has? proc (node-list-rest nl))
)
)
)
)
Then the test is
(if (our-has? our-is-p? (current-node))
(process-matching-children 'discussion)
(literal " ")
)
) ;; make element DD
I first tried
(literal " ")
Jade complained that it didn't recognize the "nbsp" entity. I
replaced it with the numeric entity as above, and it puts in an octal
240 character -- I guess Jade replaced that entity at compile time, as
it were. Filled with hope that I might be able to answer another of
my own questions (how do I insert a literal newline?), I tried
(literal "

 

")
Alas, it stripped the newlines.
--
Tim McDaniel (home); Reply-To: tmcd@xxxxxxxxx; work is tmcd@xxxxxxxxxxx
DSSSList info and archive: http://www.mulberrytech.com/dsssl/dssslist
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| (dsssl) If no P children?, Tim McDaniel | Thread | Re: (dsssl) Re: If no P children?, Adam DiCarlo |
| Re: (dsssl) Controlling line breaks, Matthew D. Fuller | Date | Re: (dsssl) Controlling line breaks, Tim McDaniel |
| Month |