The Modular DocBook Stylesheets
PrevDSSSL LibraryNext

component-child-number

Name

component-child-number — Find child-number within a component

Synopsis

(component-child-number inputnd #!optional (complist component-element-list))

Description

Finds the first ancestor of inputnd in complist and then counts all the elements of type inputnd from that point on and returns the number of inputnd. (This is like a recursive-child-number starting at the first parent of inputnd in complist.)

Author

Norman Walsh, <norm@berkshire.net>

Source Code

(define (component-child-number inputnd #!optional (complist component-element-list))
  ;; Find child-number within a component
  (let ((nd (ancestor-member inputnd complist)))
    (let loop ((nl (select-elements (descendants nd) (gi inputnd)))
	       (num 1))
      (if (node-list-empty? nl)
	  0
	  (if (node-list=? (node-list-first nl) inputnd)
	      num
	      (if (string=? (gi (node-list-first nl)) (gi inputnd))
		  (loop (node-list-rest nl) (+ num 1))
		  (loop (node-list-rest nl) num)))))))

PrevHomeNext
case-fold-upUpconstant-list