DSSSL Library Reference: Part of the Modular DocBook Stylesheet distribution
Prev |  | Next

# component-list-child-number

## Name

component-list-child-number -- Find child-number of a list of children within a component

## Synopsis

    (component-list-child-number inputnd inputlist complist)

## Description

Finds the first ancestor of `inputnd` in `complist` and then counts all the elements of the types in `inputlist` from that point on and returns the number of `inputnd`.

If the node is not found, 0 is returned.

WARNING: this requires walking over *all* the descendants of the ancestor node. This may be *slow*.

## Author

Norman Walsh, <ndw@nwalsh.com>

## Source Code

    (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))))))

Prev | Home | Next
component-list-descendant-node-list | Up | expt