Content last modified Monday 6 March 2017
hop to #bottom
Categories:
Author:
About It:
Get it:
Rate it:
  • Helpful?
  • 0 Yes
  • 0 No
Flag it:

If you'd like to provide updated information and do not have access to directly edit, please contact the site admin; thanks!

Serve your site as application/xhtml+xml

If you want to serve your Textpattern site with the proper MIME type, you need to edit publish.php, found in the /textpattern/ directory. (written for 4.0.3)

  1. Backup and open /textpattern/publish.php in a text editor
  2. Search for “text/html” (lines 115 and 439)
  3. Replace header("Content-type: text/html; charset=utf-8"); with Mark Pilgrim’s code

	if ( stristr($_SERVER["HTTP_ACCEPT"],"application/xhtml+xml") ) {
			header("content-type: application/xhtml+xml; charset=utf-8");
		}
		else {
			header("content-type: text/html; charset=utf-8");
		}

You can also download a new publish.php version too.

Article Request Count:
Posted here:
02 Jul 2006
Article modified:
06 Nov 2006

Comments/questions? Leave a message in the form.

Your comment will NOT be submitted until you click the 'Submit' button on the next pageload.

Commented (5)

I have tested it, it is ok. Thank you
I believe Philippe made a plugin to do this (and some other helpful stuff) without modifying the source. Maybe you will find it useful. Hasta-
You need to know that Gecko-based browsers (Firefox, Camino…) will switch from the default “tag soup” parser to an XML parser when a page is served with this MIME type.
They are some limitations when using this parser:
* If the XML of any page is not well-formed (for example a tag is not closed properly), the page will not display at all (a message describing the validation error will be displayed instead)
* The current XML parser of Mozilla browsers is unable to display the XHTML progressively while loading. The page will only display after it has been fully downloaded. The browsing experience may be affected by this behaviour.

Another limitation is that Javascript method document.write() , which is widely used, cannot be used when serving pages as XML. You need to use the DOM methods exclusively.
Thanks for the link to the plugin. Personally, I think if you’re editing publish.php once, why not edit the whole thing and avoid a plugin? While serving a text/html with the XHTML DTD isn’t pure, there isn’t much harm, as long as one is aware of the problems with moving to application/xhtml+xml in the future. That’s why I chose to edit publish.php with simple php.

If we’re discussing mime type differences, we might as well add different CSS behavior, most notably the treatment of the body tag.

Also, Bobby van der Sluis has a solution for document.write in real XHTML that might be of interest.

Subscribe to this article's comments RSS feed. [ ? ]   View Recent Comments across the site.

Would you care to write a comment?

You know you want to visit the Archives.

Browse

Categories


Articles

There are also tag clouds, 'cause those are fun.
Published with Textpattern