[plt-scheme] Escaping in X-expression attributes

From: Jens Axel Søgaard (jensaxel at soegaard.net)
Date: Fri Aug 9 10:49:58 EDT 2002

Hi All

I have a hard time figuring out how to get the web-server
to produce a " or a ' in the output when feeded an X-expression.
I simply can't figure out how to escape properly in the attributes
of X-expressions.

Example:

    (a ([href ""] [onClick "return mysubmit('google');"]) "Web")

is turned into

  <a href="" onclick="return minsubmit(&apos;google&apos;);">Web</a>


What I want is:

  <a href="" onclick="return mysubmit('google');">Web</a>
or
  <a href="" onclick="return mysubmit("google");">Web</a>


Transcript:

> (require (lib "xml.ss" "xml"))

> (xexpr->string '(a ([href ""] [onClick "return mysubmit('google');"])
"Web"))
"<a href=\"\" onclick=\"return mysubmit(&apos;google&apos;);\">Web</a>"

> (xexpr->string '(a ([href ""] [onClick "return mysubmit(\"google\");"])
"Web"))
"<a href=\"\" onclick=\"return mysubmit(&quot;google&quot;);\">Web</a>"


Any ideas?

--
Jens Axel Søgaard





Posted on the users mailing list.