(declare (usual-integrations))
\f
(define (write-xml xml port . options)
- (set-coding xml port)
- (write-xml-1 xml port options))
+ (write-xml* xml port options))
(define (write-xml-file xml pathname . options)
(call-with-output-file pathname
(lambda (port)
- (set-coding xml port)
- (write-xml-1 xml port options))))
-
-(define (xml->octets xml . options)
- (call-with-output-octets
- (lambda (port)
- (set-coding xml port)
- (write-xml-1 xml port options))))
+ (write-xml* xml port options))))
+
+(define (xml->string xml . options)
+ (call-with-output-string
+ (lambda (port)
+ (write-xml* xml port options))))
+
+(define (xml->bytevector xml . options)
+ (call-with-output-bytevector
+ (lambda (binary-port)
+ (write-xml* xml (binary->textual-port binary-port) options))))
+
+(define (write-xml* xml port options)
+ (set-coding xml port)
+ (write-xml-1 xml port options))
(define (set-coding xml port)
(if (port/supports-coding? port)
(define (read-xml port #!optional pi-handlers)
(receive (coding prefix) (determine-coding port)
- (parse-xml (input-port->parser-buffer port prefix)
+ (parse-xml (textual-input-port->parser-buffer port prefix)
coding
- (guarantee-pi-handlers pi-handlers 'READ-XML))))
+ (guarantee-pi-handlers pi-handlers 'read-xml))))
+
+(define (bytevector->xml bv #!optional start end pi-handlers)
+ (read-xml (binary->textual-port (open-input-bytevector bv start end))
+ pi-handlers))
(define (string->xml string #!optional start end pi-handlers)
(parse-xml (string->parser-buffer string start end)
- 'ANY
- (guarantee-pi-handlers pi-handlers 'STRING->XML)))
+ 'any
+ (guarantee-pi-handlers pi-handlers 'string->xml)))
(define (guarantee-pi-handlers object caller)
(if (default-object? object)
(http-post uri
`(,@(if (default-object? headers) '() headers)
,(make-http-header 'CONTENT-TYPE "text/xml"))
- (xml->octets (->request request 'XML-RPC)))))
+ (xml->bytevector (->request request 'XML-RPC)))))
(if (not (= 200 (http-response-status response)))
(error "HTTP error:" (http-response-reason response)))
(xml-rpc:parse-response (read-xml (http-message-body-port response)))))
(files "xml-parser")
(parent (runtime xml))
(export ()
+ bytevector->xml
read-xml
read-xml-file
string->xml
(files "xml-output")
(parent (runtime xml))
(export ()
- (xml->string xml->octets)
write-xml
write-xml-file
- xml->octets))
+ xml->bytevector
+ xml->string))
(define-package (runtime xml html)
(files "xhtml" "xhtml-entities")