<RefEntry id="component-list-descendant-node-list">
<!-- This file is generated automatically from the DSSSL source. -->
<!-- Do not edit this file! -->
<?html-filename component-descendant-list-node-list.html>

<RefMeta>
  <RefEntryTitle>component-list-descendant-node-list</RefEntryTitle>
  <RefMiscInfo Role="file">dblib.dsl</RefMiscInfo>
</RefMeta>

<RefNameDiv>
  <RefName>component-list-descendant-node-list</RefName>
  <RefPurpose>Find all elements of a list of elements in a component</RefPurpose>
</RefNameDiv>

<RefSynopsisDiv><Title>Synopsis</Title>
<Synopsis>
(component-list-descendant-node-list inputnd inputlist complist)
</Synopsis>
</RefSynopsisDiv>

<RefSect1><Title>Description</Title>

<para>
Finds the first ancestor of <literal>inputnd</literal> in <literal>complist</literal> and
then returns a list of all the elements in <literal>inputlist</literal> 
within that component.
</para>
<para>
WARNING: this requires walking over *all* the descendants
of the ancestor node. This may be *slow*.</para>


</RefSect1>

<RefSect1><Title>Author</Title>

<para>
Norman Walsh, &lt;ndw@nwalsh.com&gt;
</para>
</RefSect1>
<RefSect1><Title>Source Code</Title>

<ProgramListing>
(define (component-list-descendant-node-list inputnd inputlist complist)
  ;; Find all elements of a list of elements in a component
  (let ((nd (ancestor-member inputnd complist)))
    (let loop ((nl (descendants nd)) (result (empty-node-list)))
      (if (node-list-empty? nl)
	  result
	  (if (member (gi (node-list-first nl)) inputlist)
	      (loop (node-list-rest nl) 
		    (node-list result (node-list-first nl)))
	      (loop (node-list-rest nl) 
		    result))))))
</ProgramListing>
</RefSect1>

</RefEntry>
