[plt-scheme] html in servlets

From: Anton van Straaten (anton at appsolutions.com)
Date: Sun May 16 17:05:09 EDT 2004

ifconfig nslookup wrote:
> This would work for:
> <script language="JavaScript">
>   if (a < b)
>     a = b;
> </script>
>
> (because of the < symbol)

Ouch!  Assuming you mean that this *wouldn't* work, you're right.

Wrapping the code in a CDATA doesn't seem to solve this, either: although
the xexpr which results from an XML box which uses CDATA looks correct, when
it's converted to XML, > and < etc. are still converted to entity
references.

Another solution might be to wrap the code in a <!-- comment -->, but
DrScheme just strips the comment out, eliminating the script code.  Setting
(read-comments #t) didn't seem to affect that.

I found one way to make this work with an XML box: inside the SCRIPT
element, insert a Scheme box, and insert the script using the make-comment
procedure:

  (make-comment "
     if (a < b)
       a = b;")

You can do something similar in plain code without XML boxes:

`(script ([type "text/javascript"])
   ,(make-comment "
      if (a < b)
        a = b;"))

This isn't ideal.  I'll post a separate message about that.

Anton



Posted on the users mailing list.