;;; ;;; Common cruft required to make sxml-tools happy ;;; ;;; These are procedures that are expected, but not provided, by sxml-tools ;;; (import (only srfi-13 string-prefix? string-prefix-ci? string-index-right string-concatenate string-concatenate/shared) (prefix (only (chicken string) string-split) chicken:) (only (chicken string) substring-index) (only (chicken base) foldr add1 sub1 current-error-port error)) ;; Defined in xpath-parser, but used elsewhere... Maybe export it from xpath-parser? (define sxml:whitespace '(#\space #\return #\newline #\tab)) (define (substring? pattern str) (substring-index pattern str)) (define string-rindex string-index-right) (define (filter pred? lst) (foldr (lambda (x acc) (if (pred? x) (cons x acc) acc)) '() lst)) (define nl (string #\newline)) (define -- sub1) (define inc add1) ; like cout << arguments << args ; where argument can be any Scheme object. If it's a procedure ; (without args) it's executed rather than printed (like newline) (define (cout . args) (for-each (lambda (x) (if (procedure? x) (x) (display x))) args)) (define (cerr . args) (for-each (lambda (x) (if (procedure? x) (x (current-error-port)) (display x (current-error-port)))) args)) ;; This is a simplified version of the "string-split" procedure provided ;; by SSAX/lib/util.scm (which is 57 lines long!); this one is enough for ;; txpath and xpath-context (define (string-split str separators . rest) (if (not (null? rest)) (error (string-append "String-split called with more arguments. " "This shouldn't happen and is a bug in the " "chicken-specific code of the sxpath egg.")) (chicken:string-split str (list->string separators))))