Subject: Re: Filtering nodes From: ptyso@xxxxxxxxxxxxx Date: Thu, 9 Nov 2000 19:31:07 -0600 |
David, I'd use the more general (node-list-reduce) procedure, because it can return any type of object, not just node-lists. You want a pair of node-lists returned. Something like this works for the structures you have presented: ======================================================================== <!DOCTYPE style-sheet PUBLIC "-//James Clark//DTD DSSSL Style Sheet//EN"> (declare-flow-object-class element "UNREGISTERED::James Clark//Flow Object Class::element") (element C (let ((nl-pair (nl-filter (select-elements (children (current-node)) '("N"))))) (sosofo-append (make element gi: "DIV" (process-node-list (car nl-pair))) (make element gi: "DIV" (process-node-list (cdr nl-pair)))))) (default (make element gi: "P")) (define (nl-filter nl) (node-list-reduce nl (lambda (obj snl) (if (node-list-empty? (select-elements (follow snl) '("S"))) (cons (car obj) (node-list (cdr obj) snl)) (cons (node-list (car obj) snl) (cdr obj)))) (cons (empty-node-list) (empty-node-list)))) ========================================================================= Later, Paul Tyson On Thu, Nov 09, 2000 at 03:13:57PM -0500, Maltby, David G wrote: > I would like to write a two node-list-filters, (first-ns nl) and (last-ns > nl), > such that given the following node-list nl = (T N N S S S N), > (first-ns nl) would return (N N) which would be the two nodes following T > and before S, > and (last-ns nl) would return (N) which would be the last node in the > node-list. > > The content model for the container of these elements would be > <!element C (T?, N*, S+, N*)> > > It seems some clever use of (node-list-filter) should be able to sort this > out but I am struggling with the appropriate lambda expression. Maybe there > is a better way. I have looked through section 10.2.3 but perhaps I am not > seeing the grove for the all the nodes. Any thoughts? > > Regards, David > > > DSSSList info and archive: http://www.mulberrytech.com/dsssl/dssslist DSSSList info and archive: http://www.mulberrytech.com/dsssl/dssslist
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: Filtering nodes, Brandon Ibach | Thread | RE: Filtering nodes, Maltby, David G |
Re: Filtering nodes, Brandon Ibach | Date | RE: Filtering nodes, Maltby, David G |
Month |