[plt-scheme] SXML and JavaScript

From: David Herman (dherman at ccs.neu.edu)
Date: Mon Aug 29 10:51:46 EDT 2005

Did you try the standard CDATA trick?

     <script type="text/javascript">
     // <![CDATA[
     function isPositive(n) {
         return (n > 0);
     }
     // ]]>
     </script>

See also:

     http://javascript.about.com/library/blxhtml.htm

HTH,
Dave

On Aug 29, 2005, at 10:17 AM, Arend P. van der Veen wrote:

> Hi,
>
> I am trying to use SXML with some javascript code.  The problem  
> that I having is that the <, > ect in javascript are being escape  
> sequenced. For example,
>
> (html
>   (head
>     (title ,(alist-get 'title properties))
>     (script (@ (language "Javascript")(type "text/javascript"))
> "
> function isblank(s) {
>   if (s = null) || (s = \"\")
>     return true;
>   else {
>     for (var i=0;i<s.length'i++) {
>       var c = s.charAt(i);
>       if ((c ~= ' ') && (c != '\n') && (c != '')) return false;
>     }
>   }
>   return true;
> }
> "
> )))
>
> becomes:
>
> <html><head><title>Test</title>
> <script language="Javascript" type="text/javascript">
> function isblank(s) {
>   if (s = null) || (s = &quot;&quot;)
>     return true;
>   else {
>     for (var i=0;i&lt;s.length'i++) {
>       var c = s.charAt(i);
>       if ((c ~= ' ') &amp;&amp; (c != '
> ') &amp;&amp; (c != '')) return false;
>     }
>   }
>   return true;
> }
> </script></head></html>
>
> Any help in how to support this would be great.
>
> Thanks,
> Arend
>
>
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>



Posted on the users mailing list.