XML parser error: entity not defined

Having trouble installing Oxygen? Got a bug to report? Post it all here.
MikeM
Posts: 6
Joined: Sun Jul 01, 2012 5:31 pm

XML parser error: entity not defined

Post by MikeM »

I wrote a simple XML file and a DTD file including an entity, but when I want to check it in my browsers I get the message:

XML parser error: entity not defined.
Address: file:///Users/Mike/Documents/fb.xml
Row 8, column 22

I tried to find an answer, most refer to an add-on problem with Firefox. I, however, get this message in Firefox, Chrome and Safari. (Opera doesn't give me a message, but it doesn't show the correct text replacement either.) I work on Mac OS X 10.7.

Here are my files.
DTD:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<!ELEMENT example (some_list) >
<!ELEMENT some_list (item+)>
<!ELEMENT item (element1, element2)>
<!ELEMENT element1 (#PCDATA) >
<!ELEMENT element2 (#PCDATA) >
<!ENTITY entity1 "1234567890" >
XML:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE some_list SYSTEM "Allgemeine_Entities.dtd">
<some_list>
<item>
<element1>Some Text</element1>
<element2>more Text and &entity1;</element2>
</item>
</some_list>
As the problem appears in all my browsers, I assume it is not a browser specific problem.

Thanks for your input.
adrian
Posts: 2879
Joined: Tue May 17, 2005 4:01 pm

Re: XML parser error: entity not defined

Post by adrian »

Hi,

This happens because currently no web browser supports external entities.
For Mozilla:
https://bugzilla.mozilla.org/show_bug.cgi?id=22942

I see that at least for Firefox and Chrome there is a workaround. Declare the entities in the internal subset, in the XML.
e.g.

Code: Select all

<!DOCTYPE some_list SYSTEM "Allgemeine_Entities.dtd" [
<!ENTITY entity1 "1234567890" >
]>
Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
MikeM
Posts: 6
Joined: Sun Jul 01, 2012 5:31 pm

Re: XML parser error: entity not defined

Post by MikeM »

Hey Adrian,

Thank you very much for this very helpful answer. Excellent.

Regards,
Mike
djheru
Posts: 1
Joined: Tue Jul 17, 2012 9:53 pm

Re: XML parser error: entity not defined

Post by djheru »

Thanks for this! I was banging my head against the wall trying to figure out why my externally defined entities were not being pulled into the browser.
Post Reply