Adding string->xexpr from troels
svn: r15233
This commit is contained in:
parent
c94c436c18
commit
f409c1e36d
|
@ -463,7 +463,7 @@ END
|
|||
|
||||
(local
|
||||
[(define (test-xml->xexpr str xe)
|
||||
(test-equal? str (xml->xexpr (document-element (read-xml (open-input-string str)))) xe))
|
||||
(test-equal? str (string->xexpr str) xe))
|
||||
(define (test-xexpr->string xe str)
|
||||
(test-equal? (format "~S" xe) (xexpr->string xe) str))]
|
||||
(test-suite
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#lang scheme
|
||||
(require scheme/pretty
|
||||
"structures.ss"
|
||||
"reader.ss"
|
||||
"writer.ss")
|
||||
|
||||
;; Xexpr ::= String
|
||||
|
@ -232,6 +233,9 @@
|
|||
(write-xml/content (xexpr->xml xexpr) port)
|
||||
(get-output-string port)))
|
||||
|
||||
(define (string->xexpr str)
|
||||
(xml->xexpr (read-xml/element (open-input-string str))))
|
||||
|
||||
;; bcompose : (a a -> c) (b -> a) -> (b b -> c)
|
||||
(define (bcompose f g)
|
||||
(lambda (x y) (f (g x) (g y))))
|
||||
|
@ -241,6 +245,7 @@
|
|||
[exn:invalid-xexpr-code (exn:invalid-xexpr? . -> . any/c)]
|
||||
[xexpr/c contract?]
|
||||
[xexpr? (any/c . -> . boolean?)]
|
||||
[string->xexpr (string? . -> . xexpr/c)]
|
||||
[xexpr->string (xexpr/c . -> . string?)]
|
||||
[xml->xexpr (content/c . -> . xexpr/c)]
|
||||
[xexpr->xml (xexpr/c . -> . content/c)]
|
||||
|
|
|
@ -265,6 +265,10 @@ Converts an @tech{X-expression} into XML content.}
|
|||
|
||||
Converts an @tech{X-expression} into a string containing XML.}
|
||||
|
||||
@defproc[(string->xexpr [str string?]) xexpr/c]{
|
||||
|
||||
Converts XML represented with a string into an @tech{X-expression}.}
|
||||
|
||||
@defproc[((eliminate-whitespace [tags (listof symbol?)]
|
||||
[choose (boolean? . -> . boolean?)])
|
||||
[elem element?])
|
||||
|
|
Loading…
Reference in New Issue
Block a user