[racket] cdata section is not normalized by read-xml

From: YC (yinso.chen at gmail.com)
Date: Wed Nov 10 03:45:29 EST 2010

What do you think of changing the behavior so that the cdata-string contains
data without the cdata section wrapper?

It looks like the two main code are as follows:

;; /collects/xml/private/reader.rkt

(define (lex-tag-cdata-pi-comment in pos)
         [(#\[) (read-char in)
                (unless (string=? (read-string 6 in) "CDATA[")
                  (lex-error in pos "expected CDATA following <["))
                (let ([data (lex-cdata-contents in pos)])
                  (make-cdata start (pos) *(format "<![CDATA[~a]]>" data)*

;; /collects/xml/private/writer.rkt
;; write-xml-cdata : Cdata Nat (Nat Output-Stream -> Void) Output-Stream ->
(define (write-xml-cdata cdata over dent out)
  ;; XXX: Different kind of quote is needed, for assume the user includes
the <![CDATA[...]]> with proper quoting
  (write-xml-base* (format "~a" (cdata-string cdata)) *over dent out))

So the reader already parse out the cdata without the wrapper, but add it
back it for whatever reason.  Perhaps switching the two?

Grepping through the collects dir and the following uses make-cdata besides


(lambda strings (xml:make-cdata loc loc (string-append* strings)))))


,(make-cdata #f #f (include-template "static.html"))))


,(make-cdata #f #f (format-xexpr/errors val))))))])

and these do not look like they provide their own <![CDATA[...]]> as
instructed in the cdata documentation.

Thoughts?  Thanks,

On Tue, Nov 9, 2010 at 9:06 PM, Jay McCarthy <jay.mccarthy at gmail.com> wrote:

> It is documented that way:
> http://docs.racket-lang.org/xml/index.html#(def._((lib._xml/main..rkt)._cdata))
> I'm not sure why it was originally written that way.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20101110/97deaa0f/attachment.html>

Posted on the users mailing list.