<!doctype style-sheet PUBLIC "-//James Clark//DTD DSSSL Style Sheet//EN">
(define debug
  (external-procedure "UNREGISTERED::James Clark//Procedure::debug"))

; CALL: jade -t sgml number.sgml
; This stylesheet displays the child-number, element-number and position of all nodes.
; This stylesheet produces no output.

; Only one default construction-rule for all elements!
(default
  (sosofo-append
   (numbers (current-node))
   (positions (current-node))
   (process-children)))

(define (numbers ndl)
  (sosofo-append
   (debug-foo (gi ndl))
   (debug-foo (element-number ndl))
   (debug-foo (child-number ndl))))

(define (positions ndl)
  (sosofo-append
   (if (first-sibling? ndl)
       (debug-foo "first-sibling")
       (empty-sosofo))
   (if (absolute-first-sibling? ndl)
       (debug-foo "absolute-first-sibling")
       (empty-sosofo))
   (if (last-sibling? ndl)
       (debug-foo "last-sibling")
       (empty-sosofo))
   (if (absolute-last-sibling? ndl)
       (debug-foo "absolute-last-sibling")
       (empty-sosofo))))


(define (debug-foo obj)
  (let ((foo (lambda (o1 o2) o1)))
    (foo (empty-sosofo) (debug obj))))


