I have an XHTML document that defines several text entities in its internal DTD. I want these entities to be available in other XHTML documents without having to cut and paste the internal DTD everywhere.
The answer that seems to keep coming up for other XML files (not specifically XHTML) -- for example, here: https://stackoverflow.com/questions/13567930/how-to-use-multiple-dtd-files-in-a-single-xul -- suggests that the XHTML file I want to write would look something like this:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" [ <!ENTITY % mydtd SYSTEM "x.ent"> %mydtd; ]> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <title>Example</title> </head> <body> <p>“&x; &y;”</p> </body> </html>
... where the file x.ent has these contents:
<!ENTITY x "Hello"> <!ENTITY y "world!">
But no. At any rate, it doesn't show what I expect in either of the browsers I need to work with. I expect to see "Hello world!" enclosed in left-hand and right-hand double quotes. But Firefox says “ is an undefined entity, and Opera shows the text between <p> and </p> verbatim (displaying ampersands instead of quotation marks).
I also tried inserting the public DTD within my internal DTD, so:
<!DOCTYPE html [ <!ENTITY % publicdtd PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> %publicdtd; <!ENTITY % mydtd SYSTEM "x.dtd"> %mydtd; ]>
Then Firefox complained that &x; was an undefined entity. Opera displayed the quotation marks I expected, but still displayed &x; and &y; verbatim; no hello, no world.
I thought x.ent didn't need an XML tag, but someone put one in their example of a file of entity definitions, so I tried it. That didn't work either.
Is there some reason that this can't work in XHTML? Or is this a defect in both of these browsers? Or is there another way to share the entities among multiple files? Unfortunately, I need something that works in these two browsers, or I might as well not do it at all. But if it's a flaw in the XHTML 1.1 DTD, I can use a different version.