(import magic-pipes) (import args) (import (chicken condition)) (import (chicken process-context)) (import ssax) (receive (options operands before-exprs after-exprs usage) (parse-mp-args (command-line-arguments) '() "" "Read XML documents from standard input, and convert them to sexprs on standard output.") (unless (= (length operands) 0) (usage)) (let* ((ec (make-eval-context before-exprs '() after-exprs))) (let loop () (handle-exceptions exn (unless ;; Such an ugly hack... (string=? (get-condition-property exn 'exn 'message) "XML [22], unexpected EOF") (raise exn)) (let ((sxml (ssax:xml->sxml (current-input-port) '()))) (data-write sxml) (newline) (loop)))) (without-input-port (eval-context-end-closure ec))))