Anne van Kesteren

It is all about the XML NameSpace

And using hexadecimal entities character references. With the proper mime-type and hexadecimal character references you don't need a doctype. I would ask you if you would find it difficult to code that way. You can still use the five predefined XML entities of course: &, ", ', < and >. This way your XHTML file is independent from any doctype. I already changed my templates, since some browsers (ok, I admit, Mozilla) do not always interpreted the DTD correctly. Besides that, it is more forward compatible. This is only for the entities already specified, if you are using your own entities you will need a DTD (as far as I know, this isn't even possible using XML Schema).

Now the five tests why the xmlns attribute with the value of http://www.w3.org/1999/xhtml is more important than a DTD IMHO. All the tests are served as application/xhtml+xml:

  1. Doctype XMLNS and an entity.
  2. Doctype and an entity.
  3. Entity.
  4. XMLNS and an entity.
  5. XMLNS and an hexidecimal entity.

The first tests works, obvious. The second displays the source code, why? Because we did not declare we where using XHTML. So we can state that the xmlns takes care of that, can't we? The third crashes. The fourth crashes, since I didn't use a DTD for that test it is obvious that the entity is not known by the UA. The fifth works! Hexadecimal character references are the answer. Use them!

UPDATE: I'm not saying that you should omit the DTD. See comment 9 for more information.

Comments

  1. I don't get it. Is the objective simply to have Mozilla not barf when it receives you document? (It will bravely try to render whatever you throw at it, subject only to the limitations of the expat XML parser.) Or do you simply not believe there is any difference (or, at least any difference worth mentioning to the User-Agent) between XHTML1.0, XHTML1.1, ... (which share the same xhtml namespace declaration)?

    What you are doing is creating the XML equivalent of Tag-soup. Yes, the browser will handle it. No, it's not a good idea.

    And when are you going to get a preview button?

    Posted by Jacques Distler at

  2. I don't get it either..

    The fifth link should be # XMLNS and an hexidecimal entity. :-)

    Posted by Mark Wubben at

  3. Sorry Anne, can't say I understand the point of this either. Pick a particular representation (XHTML1.1, XHTML1.0, PDF, SVG etcetera) of content and be very explicit about sending it as such. It's very different from changing your URL space by removing extensions. In that sense you're creating a pointer to a document with many possible representations. A browser should be sent one solid version; which version is up to content negotiation.

    Posted by Gary F at

  4. Something is messed up? The fifth gives a blank page for me (using Firebird). If I look at the code, I see:

    <html><body></body></html>

    Besides this, I am strugling with the same question as my fellow commenters.

    Posted by Jeroen at

  5. The fifth has a wrong URL, use the one I posted a bit up.

    Posted by Mark Wubben at

  6. Jacques,
    All I'm saying is that the XMLNS is more important than the DOCTYPE. You can see this when you see example 1, 2 and 5 (now fixed). With only the DOCTYPE declared there is nothing to see. If the XMLNS is declared the browser associates this with the default styling for XHTML elements.

    Since the DOCTYPE seems to make no difference (except for entities) I think it works better if I use hexadecimal entities besides the 5 predefined XML entities.

    Gary F,
    This post was not about file-extension. I only hide the file extension so I could alter it later. That has nothing to do with the MIME-type that has to be used for that file.

    Posted by Anne at

  7. Anne, what is your point of this exercise? To show how browsers handle XHTML? To promote bad coding practices? Just playing around?

    The specifications of HTML4 and XHTML1 are very clear that a document type declaration is mandatory. You cannot leave it out, the namespace attribute alone is not enough! Please do not throw us back into the dark ages of tagsoup!

    Posted by Ben at

  8. Well, Ben, there is a point Anne could have made, had he not gotten sidetracked on the "xmlns" versus "DOCTYPE" thang.

    Namely, current browsers don't actually parse the DTD that you declare. They just match your DOCTYPE declaration with a set of built-in "known" DTDs. This can make life difficult for those who are attempting to exploit the Modularization of XHTML through custom DTDs.

    While it is mandatory to declare a DOCTYPE and while future browsers may make use of the information, throwing a custom DTD at current browsers (Mozilla) is basically a pig-in-a-poke, as unpredicable, really, as Anne's experiment of not setting a DOCTYPE at all.

    Posted by Jacques Distler at

  9. Jacques,
    I was trying to make that point. Thanks for adding the word 'browser' and make it more clear. I like validating (and DTD's or XML Schema's), but I don't like browsers to crash on my homemade DTD. That's why I am going to use hexadecimal entities and a custom DOCTYPE, so it won't crash.

    And I was actually trying to ask you if I'm right at this point or that I should not use hexadecimal entities in favor of the ones declared inside a DTD.

    Posted by Anne at

  10. I thought Mozilla was OK with entities declared in the DOCTYPE declaration.

    The difficulty is, as I said, that you are dealing with the unpredictable behaviour of Mozilla handling (what we've come to call here) XML Tag Soup. That behaviour might change in the next beta release. Documents which worked before might break, and vice versa.

    All in all, I'm very sympathetic to the effort to get custom DTDs to work reliably in Mozilla. But this is, currently, a very murky subject.

    Good luck!

    Posted by Jacques Distler at