1
votes

When using the application/xhtml+xml Content-Type I cannot use any named HTML entities in my javascript ( , €, etc.).

It works fine when I use a text/html Content-Type. The offending HTML entities also work fine when put in the document itself (Instead of using Javascript).

When I hit the "F12 developer tools" in IE9, I get the following error:

SCRIPT5022: DOM Exception: SYNTAX_ERR (12) 
    javascript.js, line 7 character 2
XML5645: The specified entity has not been declared. 
    , line 1 character 42

Firefox gives a similar error:

[11:19:33.491] undefined entity:1
[11:19:33.493] uncaught exception: [Exception... "An invalid or illegal string was specified"  code: "12" nsresult: "0x8053000c (NS_ERROR_DOM_SYNTAX_ERR)"  location: "http://arp242.net/entity-test/javascript.js Line: 8"]

And then execution stops.

I created a test page for testing/isolating where the problem is: http://arp242.net/entity-test/

As far as I can figure out, named HTML entities are perfectly valid in XHTML (http://www.w3.org/TR/2002/REC-xhtml1-20020801/#h-A2)

Does anyone have a clue how to resolve the problem? I can enter the characters (€, —, “, ”, etc.) or numeric &#..; values and that works, but I'd rather use HTML entities. There is also quite a bit of existing (3rd party) code which uses HTML entities and I'd rather not convert all of that.

Thanks!

1

1 Answers

1
votes

XML hasn't text named entities, you can define them either in doctype or replace text named entities with char code entites ( eg.   is   etc. )

http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references ( Take unicode code point in decimal )