;; Refer to this as ;; PUBLIC "-//O'Reilly//NONSGML Procedures::ISO/IEC 10179:1996 ;; Reference Implementations//EN" ;; New procedures can be added as necessary; only add here if they are ;; sample implementations from the text of the DSSSL Standard. ;; (attribute) from ISO/IEC 10179 (define (attribute name nl) (node-list-map (lambda (snl) (named-node name (attributes snl))) nl)) ;; (cadr) from ISO/IEC 10179 (define cadr (lambda (x) (car (cdr x)))) ;; (grove-root) from ISO/IEC 10179 (define (grove-root nl) (node-list-property 'grove-root nl)) ;; (match-element?) is defined in ISO/IEC 10179, but no implementation ;; is given. This implementation from James Clark. (define (match-element? pattern snl) (not (node-list-empty? (select-elements snl pattern)))) ;; (node-list-filter) from ISO/IEC 10179 with small change to avoid ;; reversing the order of nodes (define (node-list-filter proc nl) (node-list-reduce nl (lambda (result snl) (if (proc snl) (node-list result snl) result)) (empty-node-list))) ;; (node-list-last) from ISO/IEC 10179 - implemented differently from ;; reference implementation due to Jade problem with node-list-length (define (node-list-last nl) (node-list-first (node-list-reverse nl))) ;; original (node-list-last) definition: ;(define (node-list-last nl) ; (node-list-ref nl ; (- (node-list-length nl) 1))) ;; (node-list-property) from ISO/IEC 10179 (define (node-list-property prop nl) (node-list-map (lambda (snl) (node-property prop snl default: (empty-node-list))) nl)) ;; (node-list-reduce) from ISO/IEC 10179 (define (node-list-reduce nl combine init) (if (node-list-empty? nl) init (node-list-reduce (node-list-rest nl) combine (combine init (node-list-first nl))))) ;; (origin) from ISO/IEC 10179 (define (origin nl) (node-list-property 'origin nl)) ;; (referent) from ISO/IEC 10179 (define (referent nl) (node-list-property 'referent nl))