[RubyMine 6] "Unescaped xml character" (using '<' characters with Doctype)

Hi everyone,

I was testing a javascript on a view on a RubyMine 4.5 project, and when I tried to add it on my working RubyMine 6 project, I've got an error.

Here's a part of the view :

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<script type="text/javascript">
     window.onload = function() {

          var elements = document.getElementsByTagName("tbody");
          for(var i=0; i<elements.length; i++)

I've got an error (yes, in red, not just a warning) on the "<" character saying :

Unescaped xml character
This inspection checks that the script tag content is valid XML

And it's the same error for all the "<" I'm using in my for loops.
I don't know how to get ride of this problem, specially that it worked just fine on RubyMine 4 (with the same file headers and everything, it was just a copy/past of the javascript function).
Can anyone help me please? Thank you.

PS: Btw the javascript function works just fine when running, it's just that I've got a bunch of red errors in the view page, but it doesn't affect the running.


I think the problem is that you use strict xhtml doctype, if you think that it is ok to have such characters in your html then you should use some other doctype.



Hi Oleg, thanks for your answer.

Yes, the problem comes from the doctype.
When I put:

 <!DOCTYPE html> 

alone, it seems to work perfectly.
However, I still can't figure out how to solve it, I've tried all the doctypes and no one seems to work.
Specially that I have in my code something like :

ajaxRequest.setRequestHeader("X-CSRF-Token", '<%= form_authenticity_token.to_s %>')
for(var i=0; i<elements.length; i++)
     { ...

As you can see, I still can't use the '<' characters.
How come it worked just fine on older versions of RubyMine?
And what can I do to make it work on RubyMine 6?



I'm not sure I've completely understood you reply :(

At first you say that html5 doctype resolves the problem, but later you say that no doctype resolves the problem.
Do you mean that original problem has been fixed by html5 doctype, but even html5 doesn't solve problem you have with erb injection?
Perhaps screenshot or a short screencast would be useful here.

Regards, Oleg.


Hi again,

I'm sorry if my answer was not clear.
The HTML5 doctype did work actually as I said, but I was still looking for an XHTML doctype, and these are the ones that did not work.
I should have specified that I was still using the XHTML doctype, and that the change should come from the code and not the doctype.

Anyway, I solved my problem by using CDATA sections, worked wonder!
But thanks, your answer was helpful!



Please sign in to leave a comment.