TEXTAREA elements

Andy Bennett <[email protected]> Mon, 2 Sep 2013 21:22:58 +0100
Newsgroups gmane.lisp.scheme.ssax-sxml
Message-ID <[email protected]>
Hi,

I'm happily using the CHICKEN port of the SSAX tools:

https://wiki.call-cc.org/eggref/4/sxml-transforms

https://wiki.call-cc.org/eggref/4/ssax

...to generate HTML for use in web browsers.


Despite generally being XML tooling it seems to know a few HTML-isms
such as which things are self closing and which aren't:

-----
#;19> (SXML->HTML `(img))
<img />#t
#;20> (SXML->HTML `(textarea))
<textarea></textarea>#t
-----

However, it doesn't seem to know that an HTML TEXTAREA element should
only contain PCDATA, not XML subtrees:

-----
(use sxml-transforms)

(define html-rules `((literal *preorder* . ,(lambda (t b) b))
		     . ,universal-conversion-rules*))

(define (sxml->html sxml)
    (SRV:send-reply (pre-post-order* sxml html-rules)))


#;3> (sxml->html '(div (div hello)))

<div>
<div>hello</div></div>#t

#;4> (sxml->html '(textarea (div hello)))
<textarea>
<div>hello</div></textarea>

...but <textarea> is defined as containing only PCDATA whereas <div>
contains %flow:

http://www.w3.org/TR/html401/interact/forms.html#h-17.7

http://www.w3.org/TR/html4/struct/global.html#edef-DIV

so I'd expect something like

#;6> (sxml->html `(textarea ,(with-output-to-string (lambda ()
(sxml->html '(div hello))))))
<textarea>
&lt;div&gt;hello&lt;/div&gt;</textarea>


edge cases:

#;10> (sxml->html '(textarea (div (@ (hello "\"what\"")))))
<textarea>
<div hello="&quot;what&quot;"></div></textarea>

... is irreversible because the browser will map " to " and &quot; to "
as well.


#;12> (sxml->html `(textarea ,(with-output-to-string (lambda ()
(sxml->html '(div (@ (hello "\"what\""))))))))
<textarea>
&lt;div
hello=&quot;&amp;quot;what&amp;quot;&quot;&gt;&lt;/div&gt;</textarea>
-----
 -- http://jpb.li/gMjQ5



Is this considered a bug in the tooling or is it up to me to encode my
own TEXTAREA contents in my application?



Thanks for your time and good work on a neat toolset! :-)





Regards,
@ndy

-- 
[email protected]
http://www.knodium.com/


------------------------------------------------------------------------------
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58040911&iu=/4140/ostg.clktrk