Custom DTDs interpreted incorrectly

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, Explorer Mac, Mozilla, Safari | Reported on 2 February 2005.

This site is no longer maintained. I’m sorry, but it’s just too much work for too little return. You can continue to browse old bug reports, though.




Search reports by browser:

Atom RSS

Comments

(Add your own)

1 Posted by Rogier Steehouder on 2 February 2005 | Permalink

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.

2 Posted by ppk on 2 February 2005 | Permalink

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,

3 Posted by Johnnie Blevins on 2 February 2005 | Permalink

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.

4 Posted by Rogier Steehouder on 3 February 2005 | Permalink

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.

5 Posted by Sören Kuklau on 18 June 2005 | Permalink

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.

6 Posted by zcorpan on 1 September 2006 | Permalink

According to the parsing section in Web Applications 1.0 (draft) Opera is wrong and the others are correct. http://whatwg.org/specs/web-apps/current-work/#parsing

7 Posted by Chris Hester on 22 November 2007 | Permalink

I get a warning from the W3C Validator that the page is not valid XHTML. I'm using Firefox 3 on Mac to test with.