RE: (dsssl) "Default" processing rule? (summary of responses)

Subject: RE: (dsssl) "Default" processing rule? (summary of responses)
From: MARK.WROTH@xxxxxxxxxxx (Wroth, Mark)
Date: Tue, 3 Apr 2001 12:50:07 -0700
I asked

>>How can I (simply) define a set of rules that will ignore everything
>>*except* an element that can be found at several levels?
>>
>>Setting (default (empty-sosofo)) results in everything being ignored,
>>presumably because the parent elements of the one I want are not
processing
>>their children.

and Christopher Maden replied

>Try something like
>
>(default (process-node-list (element-children)))
>
>(element one-I-want
>   (do-something))
>
>where (element-children) is defined as:
>
>;; (element-children snl) finds all of the elements that are direct
>;; children of singleton nodelist "snl".  This is useful for
>;; filtering, processing, and counting, when you're not interested in
>;; any text, PI, or comment nodes.
>(define (element-children #!optional (snl (current-node)))
>   (select-by-class (children snl)
>                    'element))

This solution does exactly what I was looking for.  Thank you.

As a result, I did not try to implement Peter Nilsson's suggestion

P> Couldn't you do a query on the subtree for the elements yoy want to
process
P> (the programlisting elements) and then use (process-node-list) to process
P> the result. Something like:
P> (process-node-list (q-element 'programlisting))
P> (untested.)

although that approach seems reasonable.

 DSSSList info and archive:  http://www.mulberrytech.com/dsssl/dssslist

Current Thread