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

From: YC (yinso.chen at gmail.com)
Date: Wed Nov 10 16:44:27 EST 2010

Yeah I already have both make-cdata* and cdata-string* implemented.

The usage you described make sense, but it seems to me using a parameter to
control its logic there (specifically for the output - the input should just
be the parsed input without the cdata wrapper) will satisfy the needs and
"safer", since otherwise we are leaving it to users passing in the right
format.

Something like:

(define xml-write-mode (make-parameter 'normal)) ;; or 'html, which won't
create the cdata wrapper.

(define (write-xml-cdata cdata over dent out)
  (write-xml-base (format (case xml-write-mode ((html) "~a") (else
"<![CDATA[~a]]>")) (cdata-string cdata)) over dent out))


Cheers,
yc

On Wed, Nov 10, 2010 at 4:39 AM, Jay McCarthy <jay.mccarthy at gmail.com>wrote:

> I think a better thing to do is for users who want it to make
>
> make-cdata* and cdata-string*
>
> which add the wrappers themselves.
>
> The places you're referring to in the code abuse this property of
> cdata to generate unquoted XML strings. This is very useful in HTML
> generation because it is not exactly XML. (For example, most browsers
> will break if you XML-encode Javascript strings.)
>
> Jay
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20101110/973e8997/attachment.html>

Posted on the users mailing list.