[racket] read-xml: lex-error when reading Javascript

From: Alegria Baquero (abaquero at uci.edu)
Date: Fri May 2 21:34:56 EDT 2014

Great. Thanks for your help. I will try first using the CDATA tags.
Thanks again.


On Fri, May 2, 2014 at 5:46 PM, Matthew Butterick <mb at mbtype.com> wrote:

> The handling of <script> and <style> tags is a notable difference between
> XML & HTML. If you want your HTML to be usable as XML, then you have to
> enclose the contents of any <script> or <style> tag in a CDATA tag.
> (Whereas HTML parsers assume this is true by default — in that case, CDATA
> tags aren't wrong, they're just unnecessary.)
>
> If your HTML template is a static file, you can just put the CDATA tags in
> manually.
>
> If you're using x-expressions to generate the HTML, the xexpr->html
> function in my txexpr library is a replacement for xexpr->string that will
> add the CDATA tags.
>
> raco pkg install txexpr
>
>
>
> On Apr 25, 2014, at 1:01 PM, Alegria Baquero <alegriabaquero at gmail.com>
> wrote:
>
> > Hello,
> >
> > I am using the web-server/servlet library to deploy an html:
> >
> > (let ((start (lambda (req)
> >                  (response/xexpr
> >                   (string->xexpr (include-template "ui/page.html"))))))
> >
> >
> > Page.html includes Javascript code and everything works well until I try
> to use a comparison operator.  So for example, when read-xml tries to read
> the javascript for loop
> >
> > for (var i=0;i<nodeList.length;i++) {
> >                     alert("hello");
> >                 }
> >
> > It gives the following error:
> >
> > read-xml: lex-error: at position 42.59/1747: expected / or > to close
> tag `nodeList.length'
> >
> > It turns out it believes the operator '<' is an opening xml tag.
> >
> > Has anyone found a way to fix/circumvent this problem?
> >
> > Thanks a lot.
> >
> >
> > ____________________
> >  Racket Users list:
> >  http://lists.racket-lang.org/users
>
>


-- 
---------------------------------------------------------------------------------------
PhD candidate
Department of Informatics
Donald Bren School of Information and Computer Sciences
University of California, Irvine
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20140502/5527c698/attachment.html>

Posted on the users mailing list.