home *** CD-ROM | disk | FTP | other *** search
- ;;
- ;; xselement.vsc
- ;;
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;; xs-elementâAâNâZâT
- (define (extract-sum-aux contents)
- (let* ((r #f))
- (for-each
- (lambda (x) (if r #f (set! r (extract-sum x))))
- contents)
- r)
- )
-
- (define (extract-sum xs-element)
- (cond
- ((string? xs-element) #f)
- ((eq? 'sum (caar xs-element)) (car xs-element))
- (else (extract-sum-aux (cdr xs-element))))
- )
-
- (define (replace-sum xs-element replacement)
- (cond
- ((string? xs-element) xs-element)
- ((eq? 'sum (caar xs-element)) replacement)
- (else
- (cons
- (car xs-element)
- (map
- (lambda (x) (replace-sum x replacement))
- (cdr xs-element)))))
- )
-
- (define (xs-element->xml xs-element)
- (cond
- ((string? xs-element) xs-element)
- (else
- (string-append
- (xs-stag->xml (car xs-element))
- (xs-contents->xml (cdr xs-element))
- (xs-etag->xml (car xs-element)))))
- )
-
- (define (xs-stag->xml xs-tag)
- (let* ((s (string-append )))
- (string-append
- "<"
- (symbol->string (car xs-tag))
- (apply
- string-append
- (map
- (lambda (x)
- (string-append " "
- (symbol->string (car x))
- "=\""
- (cdr x)
- "\""))
- (cdr xs-tag)))
- ">")
- )
- )
-
- (define (xs-etag->xml xs-tag)
- (string-append "</" (symbol->string (car xs-tag)) ">")
- )
-
- (define (xs-contents->xml contents)
- (apply
- string-append
- (map
- (lambda (x)
- (xs-element->xml x))
- contents))
- )
-