Subject: Re: Counting Nodes From: Matthias Clasen <clasen@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> Date: Fri, 25 Feb 2000 17:14:25 +0100 |
> > I tested Matthias' elegant procedure: > > (define (text-node-cnt #!optional (cur-text-node (current-node))) > (node-list-length > (node-list-filter > (lambda (snl) (not (attribute-string "type" snl))) > (preced cur-text-node)))) > > and it works as well as my first attempt (well, it's one off but that is > minor), however it is too elegant for me and I could not successfully modify > the filter to get rid of the (not (gi snl)) as well as the (not > (attribute-string "type" snl)). It will be a good exercise for me when > deadlines are not so pressing. I need to understand mapping a procedure > over a list better. > Well, I overlooked the issue with unwanted non-element nodes, this version should filter them away (untested): (define (text-node-cnt #!optional (cur-text-node (current-node))) (node-list-length (node-list-filter (lambda (snl) (and (equal? (gi snl) "TEXT") (not (attribute-string "type" snl)))) (preced cur-text-node)))) -- Matthias Clasen, Tel. 0761/203-5606 Email: clasen@xxxxxxxxxxxxxxxxxxxxxxxxxx Mathematisches Institut, Albert-Ludwigs-Universitaet Freiburg DSSSList info and archive: http://www.mulberrytech.com/dsssl/dssslist
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: Counting Nodes, Maltby, David G | Thread | Re: Counting Nodes, Brandon Ibach |
Re: Emulation of XSL's id() in DSSS, Toby Speight | Date | RE: Emulation of XSL's id() in DSSS, Pawson, David |
Month |