Custom DTDs interpreted incorrectly

Atom RSS

This site heavily relies on bug reports created by its readers. Anyone can report a bug and be published.

Main navigation:




Search reports by browser:

When creating custom DTDs like the one below, all browsers except Opera see the end of the ATTLIST as the end of the DOCTYPE. The result is that they print "]>" on the screen.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
[
<!ATTLIST p behavior CDATA #IMPLIED>
]>

Test page. Workaround is not included
Reported by ppk.

Explorer 5-6 Windows, Explorer 7 beta 2, Explorer Mac, Mozilla, Safari | Reported on 2 February 2005.

Comments

(Add your own)

Posted by Rogier Steehouder on 2 February 2005

1

Firefox 1.0 (and I assume most Gecko browsers) does this right if you deliver xhtml pages as "application/xhtml+xml". If served as "text/html" it will make the mistake.

Posted by ppk on 2 February 2005

2

I've heard this before, but haven't yet seen any evidence. Could you please create a test page that proves this and leave a link to it here in the comments?

Thanks,

Posted by Johnnie Blevins on 2 February 2005

3

He's right. I just tried it. This bug wasted multiple hours of my time a few months back, making me think I just didn't understand what I was doing. Thanks for pointing it out, and thanks Roger for pointing out the solution.

I took the liberty of copying the source of your frame into two test pages on my server.

http://johnnieb.the-knack.com/dtd.html and
http://johnnieb.the-knack.com/dtd.xhtml

are the same page, just with different extensions. The xhtml displays as it should, without the additional ]>.

I also checked this in Safari, and it, too, displays properly with the xhtml served as application/xhtml+xml.

Posted by Rogier Steehouder on 3 February 2005

4

Thank you Johnnie, that saves me the trouble.

The trick I tried at the time is to include a custom entity to obscure my e-mail address.

Defining <!ENTITY nw "nowhere.com"> makes an e-mail address look like "me@&nw;", which I hope no spider can figure out, but any decent xml parser can.

Posted by Sören Kuklau on 18 June 2005

5

While XHTML 1.0 Transitional allows the use of the SGML-HTML content-type, i.e. text/html, for legacy compatibility reasons (the result *not* being XML, and *not* being allowed to be parsed as such!), any other DTD does not.

Since your DTD is custom (even though it is XHTML 1.0 Transitional-*derived*), browsers are supposed to render the markup as XML, and to disregard the aforementioned exemption rule. Since you serve the page as text/html, i.e. SGML, not XML, browsers parse it as such, and in that case, the ]> characters are just that -- characters, not parts of a command.

IOW, while Opera does what you expect it to, it does so incorrectly, and the bug as you describe it isn't one.

Post a comment

Commenting guidelines:

  1. When quoting specs, articles or your own research, please include a URL of the document.
  2. Test your stuff. When reporting browser behaviour, make sure that your report is correct.

Yes