|
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)))
(node-list-length
(node-list-filter
(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.
Regards,
/Peter
--
'(#\P . (#\e . (#\t . (#\e . (#\r)))))
DSSSList info and archive: http://www.mulberrytech.com/dsssl/dssslist
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: Counting Nodes, Brandon Ibach | Thread | RE: Counting Nodes, Maltby, David G |
| RE: Emulation of XSL's id() in DSSS, Pawson, David | Date | Re: Emulation of XSL's id() in DSSS, Ralf Kempkens |
| Month |