I've been having trouble using XHTML as the main DTD and adding my own as a secondary. I've googled and find plenty of discussions or articles about XML or XHTML, but I can't seem to find what I'm looking for. does anyone know how to do this? Thanks in advance.

Alcides.

Dani AI

Generated

Short answer: that stray "]>" in IE means the browser's HTML parser is seeing part of the DOCTYPE/internal subset instead of an XML parser. Parameter entities and internal DTD subsets are processed only by an XML processor; when the document is delivered as text/html (or when there is a BOM or stray bytes before the prolog), non‑XML parsers such as legacy IE can render fragments of the DOCTYPE as page content. That explains why Firefox (XML‑aware) looked fine while IE printed characters.

Two practical paths:

  • Serve the document as true XML (application/xhtml+xml) so the XML parser handles the DOCTYPE and entities. Example (PHP):

    header('Content-Type: application/xhtml+xml; charset=utf-8');

    Care must be taken to remove any BOM or leading whitespace and to guarantee well‑formed XML. Note that historic IE versions did not accept application/xhtml+xml, so compatibility must be considered.

  • If pages must be served as text/html (to support older IE), do not rely on runtime client parsing of external DTDs or parameter entities. Expand/include the DTD contents at build time or on the server (XInclude/XSLT or templating) so the client only receives final HTML. For modern projects, prefer a simple HTML5 doctype and use data- attributes or microformats for custom metadata.

Quick checklist (relevant to ): verify the HTTP Content-Type, save files without a BOM and with no leading whitespace, validate the file with an XML tool (xmllint or a W3C validator) to catch DTD syntax issues, and avoid adding a trailing slash to the DOCTYPE close — the internal subset closes with ]>, not "/>". The suggestion by to add a slash will emit literal characters. For immediate browser compatibility the safest fix is server-side expansion or switching to a plain HTML doctype.

Recommended Answers

All 5 Replies

I couldn't find the "edit" button, so I'm adding a reply. Here is the code I have above my opening html tag.

<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" [
  <!ENTITY % html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    %html;
	<!ENTITY % ft7777 SYSTEM "">
    %ft7777;
]>

In IE it shows a "]>" at the top. But in Firefox, it seems to be okay. I'm thinking that IE has a stricter parser so I'm trying to rely on that more than Firfox's. Not to mention a lot of people still use IE. Thanks again.

Alcides.

post........? Ugh this day sucks sorry I can't help

Try it this way. Added / on very last line.

<!ENTITY % ft7777 SYSTEM "">
    %ft7777;
] />

That SO makes a lot of sense. I'm gonna try it when get home from work. Thanks, DanceInstructor.

Alcides.

I don't know if it will work or not :-| Its just a guess.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.