You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
12 lines
581 B
Racket
12 lines
581 B
Racket
10 years ago
|
#lang racket/base
|
||
10 years ago
|
(require xml racket/port racket/contract "define.rkt")
|
||
10 years ago
|
(provide (all-defined-out))
|
||
|
|
||
10 years ago
|
(define+provide+safe (xml-string->xexprs str)
|
||
10 years ago
|
(string? . -> . (values xexpr? xexpr?))
|
||
|
(define xml-doc (with-input-from-string str (λ _ (permissive-xexprs #t) (read-xml))))
|
||
|
(values (xml->xexpr (document-prolog xml-doc)) (xml->xexpr (document-element xml-doc))))
|
||
|
|
||
10 years ago
|
(define+provide+safe (xexprs->xml-string prolog-xexpr root-xexpr)
|
||
10 years ago
|
(xexpr? xexpr? . -> . string?)
|
||
|
(with-output-to-string (λ _ (write-xml (document (xexpr->xml prolog-xexpr) (xexpr->xml root-xexpr) null)))))
|