RE: Counting Nodes

Subject: RE: Counting Nodes
From: Peter Nilsson <pnidv96@xxxxxxxxxxxxxx>
Date: Fri, 25 Feb 2000 18:13:58 +0100 (CET)
On Fri, 25 Feb 2000, Maltby, David G wrote:

> 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))))
Use select-by-class, so something like (untested):

(define (text-node-cnt #!optional (cur-text-node (current-node)))
       (lambda (snl) (not (attribute-string "type" snl)))
       (select-by-class (preced cur-text-node) 'element)))

At least in (Open)Jade, this is more efficient thatn Brandon's approach,
since it only applies an expression language procedure to the nodes of
class element (and not every character). This can make a difference if you
use this on a large piece of a document.


'(#\P . (#\e . (#\t . (#\e . (#\r)))))

 DSSSList info and archive:

Current Thread