1

tl;dr: How do you include a file in the DOCTYPE declaration of an XHTML file? The solution from this answer doesn't work, giving different types of errors in the different browsers.


Longer version:
I am interested in defining character entities for XHTML files. One disadvantage of XHTML5 is that you can't use entity references such as   and é, only the five basic XML ones.

Reverting to the XHTML 1 DOCTYPE would work (since the XHTML DTD contains definitions for all the entities) but then the validator complains about all the new XHTML5 features in the file.

Reverting the file type to text/html would also work, but then it wouldn't be XHTML any more! (Defining new entities doesn't work in HTML, only in XHTML.)

So the solution is to actively add all the entity names to the DOCTYPE declaration.

<!DOCTYPE html
   [
      <!ENTITY nbsp   "&#160;">
      <!ENTITY eacute "&#233;">
   ]
>

This works great! But including hundreds of entities this way would not be very efficient. Doing it by way of an include file would be much better.
I found this answer which seems to do exactly what I need...

<!ENTITY % xhtml-special SYSTEM "xhtml-special.ent">
%xhtml-special;

but it doesn't work. If I try that, I get errors: PEReference: %xhtml-special; not found in Chromium; XML Parsing Error: undefined entity in SeaMonkey.

So does anybody know how it should be done? With a working example?

Community
  • 1
  • 1
Mr Lister
  • 45,515
  • 15
  • 108
  • 150

0 Answers0