|
|
@ -1,31 +1,28 @@
|
|
|
|
#lang racket/base
|
|
|
|
#lang racket/base
|
|
|
|
(require sugar/define (prefix-in xml: xml) racket/match)
|
|
|
|
(require sugar/define xml racket/match)
|
|
|
|
(provide (all-defined-out) cdata? cdata xexpr->string xexpr?)
|
|
|
|
(provide (all-defined-out) cdata? cdata valid-char? xexpr->string xexpr?)
|
|
|
|
|
|
|
|
|
|
|
|
; Section 2.2 of XML 1.1
|
|
|
|
;; Section 2.2 of XML 1.1
|
|
|
|
; (XML 1.0 is slightly different and more restrictive)
|
|
|
|
;; (XML 1.0 is slightly different and more restrictive)
|
|
|
|
(define (valid-char? i)
|
|
|
|
;; make private version of my-valid-char to get consistent results with 6.0
|
|
|
|
|
|
|
|
(define (my-valid-char? i)
|
|
|
|
(and (exact-nonnegative-integer? i)
|
|
|
|
(and (exact-nonnegative-integer? i)
|
|
|
|
(or (<= #x1 i #xD7FF)
|
|
|
|
(or (<= #x1 i #xD7FF)
|
|
|
|
(<= #xE000 i #xFFFD)
|
|
|
|
(<= #xE000 i #xFFFD)
|
|
|
|
(<= #x10000 i #x10FFFF))))
|
|
|
|
(<= #x10000 i #x10FFFF))))
|
|
|
|
|
|
|
|
|
|
|
|
(define (xexpr? x)
|
|
|
|
(define (my-xexpr? x)
|
|
|
|
(or (txexpr? x) (xml:xexpr? x) (valid-char? x)))
|
|
|
|
(or (txexpr? x) (xexpr? x) (my-valid-char? x)))
|
|
|
|
|
|
|
|
|
|
|
|
(define cdata xml:cdata)
|
|
|
|
|
|
|
|
(define cdata? xml:cdata?)
|
|
|
|
|
|
|
|
(define xexpr->string xml:xexpr->string)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(define (txexpr-short? x)
|
|
|
|
(define (txexpr-short? x)
|
|
|
|
(match x
|
|
|
|
(match x
|
|
|
|
[(list (? symbol? name) (? xexpr?) ...) #t]
|
|
|
|
[(list (? symbol? name) (? my-xexpr?) ...) #t]
|
|
|
|
[else #f]))
|
|
|
|
[else #f]))
|
|
|
|
|
|
|
|
|
|
|
|
(define (txexpr? x)
|
|
|
|
(define (txexpr? x)
|
|
|
|
(or (txexpr-short? x)
|
|
|
|
(or (txexpr-short? x)
|
|
|
|
(match x
|
|
|
|
(match x
|
|
|
|
[(list (? symbol?) (list (list (? symbol?) (? string?)) ...) (? xexpr?) ...) #t]
|
|
|
|
[(list (? symbol?) (list (list (? symbol?) (? string?)) ...) (? my-xexpr?) ...) #t]
|
|
|
|
[else #f])))
|
|
|
|
[else #f])))
|
|
|
|
|
|
|
|
|
|
|
|
(define (txexpr-tag? x)
|
|
|
|
(define (txexpr-tag? x)
|
|
|
@ -44,7 +41,7 @@
|
|
|
|
(and (list? x) (andmap txexpr-attr? x)))
|
|
|
|
(and (list? x) (andmap txexpr-attr? x)))
|
|
|
|
|
|
|
|
|
|
|
|
(define (txexpr-element? x)
|
|
|
|
(define (txexpr-element? x)
|
|
|
|
(xexpr? x))
|
|
|
|
(my-xexpr? x))
|
|
|
|
|
|
|
|
|
|
|
|
(define (txexpr-elements? x)
|
|
|
|
(define (txexpr-elements? x)
|
|
|
|
(and (list? x) (andmap txexpr-element? x)))
|
|
|
|
(and (list? x) (andmap txexpr-element? x)))
|
|
|
|