Sophie

Sophie

distrib > Mageia > 7 > i586 > media > core-release > by-pkgid > 6b3585ea67ce3e79c9049b5b33294cdd > files > 627

docbook-style-dsssl-doc-1.79-16.mga7.noarch.rpm

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

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

<RefNameDiv>
  <RefName>component-list-child-number</RefName>
  <RefPurpose>Find child-number of a list of children within a component</RefPurpose>
</RefNameDiv>

<RefSynopsisDiv><Title>Synopsis</Title>
<Synopsis>
(component-list-child-number inputnd inputlist complist)
</Synopsis>
</RefSynopsisDiv>

<RefSect1><Title>Description</Title>

<para>
Finds the first ancestor of <literal>inputnd</literal> in <literal>complist</literal> and
then counts all the elements of the types in <literal>inputlist</literal>
from that point on and returns the number of <literal>inputnd</literal>.
</para>
<para>
If the node is not found, 0 is returned.
</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-child-number inputnd inputlist complist)
  ;; Find child-number of a list of children within a component
    (let loop ((nl (component-list-descendant-node-list
		    inputnd inputlist complist))
	       (num 1))
      (if (node-list-empty? nl)
	  0
	  (if (node-list=? (node-list-first nl) inputnd)
	      num
	      (loop (node-list-rest nl) (+ num 1))))))
</ProgramListing>
</RefSect1>

</RefEntry>