REXML bombs out in a javascript section of a well formed XHTML document

Discussion in 'Ruby' started by Xeno Campanoli, Jul 1, 2005.

  1. As far as I can see, this javascript should just be text for the XML parser,
    n'est-ce pas? But I bomb out several lines into it with:

    Illegal character '&' in raw string (referring to a javascript and (&&) operator
    presumably. So, do we need to preparse the javascript out or something to be
    able to do this stuff? What gives with that?

    xc
    Xeno Campanoli, Jul 1, 2005
    #1
    1. Advertising

  2. Xeno Campanoli

    James Britt Guest

    Re: REXML bombs out in a javascript section of a well formed XHTMLdocument

    Xeno Campanoli wrote:
    > As far as I can see, this javascript should just be text for the XML parser,
    > n'est-ce pas? But I bomb out several lines into it with:


    "this javascript" did not make it to my mail reader; did you include it?
    >
    > Illegal character '&' in raw string (referring to a javascript and (&&) operator
    > presumably. So, do we need to preparse the javascript out or something to be
    > able to do this stuff? What gives with that?


    Unless you are hiding the script element content with XML comment markup
    or wrapping it in CDATA markup, then it is interpreted as normal XML
    fodder, and the ampersand has a special meaning.

    James
    --

    http://www.ruby-doc.org - The Ruby Documentation Site
    http://www.rubyxml.com - News, Articles, and Listings for Ruby & XML
    http://www.rubystuff.com - The Ruby Store for Ruby Stuff
    http://www.jamesbritt.com - Playing with Better Toys
    James Britt, Jul 1, 2005
    #2
    1. Advertising

  3. Xeno Campanoli

    Phrogz Guest

    James Britt wrote:
    > Unless you are hiding the script element content with XML comment markup
    > or wrapping it in CDATA markup, then it is interpreted as normal XML
    > fodder, and the ampersand has a special meaning.


    To elaborate by example:

    <?xml version="1.0"?>
    <foo><script>if (a && b || 5 < 6) alert("Hi!")</script></foo>
    ^---------^-------- ILLEGAL CHARACTERS

    <?xml version="1.0"?>
    <foo><script><![CDATA[if (a && b || 5 < 6)
    alert("Hi!")]]></script></foo>
    LEGAL!


    <?xml version="1.0"?>
    <foo><script>if (a &amp;&amp; b || 5 &lt; 6)
    alert("Hi!")</script></foo>
    LEGAL!
    Phrogz, Jul 1, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. wtsnet
    Replies:
    4
    Views:
    669
    wtsnet
    Nov 25, 2003
  2. Assimalyst
    Replies:
    4
    Views:
    14,004
    Brock Allen
    Jul 25, 2005
  3. mike
    Replies:
    3
    Views:
    14,669
    Karl Seguin
    Nov 24, 2005
  4. LetMeDoIt
    Replies:
    3
    Views:
    187
    Bob Barrows [MVP]
    May 21, 2007
  5. Replies:
    0
    Views:
    40
Loading...

Share This Page