Topic: XHTML - which MIME type do you use? (and how) (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=26134" title="Pages that link to Topic: XHTML - which MIME type do you use? (and how) (Page 1 of 1)" rel="nofollow" >Topic: XHTML - which MIME type do you use? (and how) <span class="small">(Page 1 of 1)</span>\

 
Pugzly
Paranoid (IV) Inmate

From: 127.0.0.1
Insane since: Apr 2000

posted posted 07-01-2005 19:01

Was just killing some time today, and ran across some discussions about using
application/xhtml+xml for XHTML documents instead of text/html.

Curious as to what everyone is using, and why...

reisio
Paranoid (IV) Inmate

From: Florida
Insane since: Mar 2005

posted posted 07-01-2005 19:14

You should use application/xhtml+xml - that is the proper type.

IE6 will wig out over it, though, so if you care about IE and want to stick with XHTML (you could just serve HTML to IE) you should serve application/xml or text/html for IE.

Pugzly
Paranoid (IV) Inmate

From: 127.0.0.1
Insane since: Apr 2000

posted posted 07-01-2005 19:31

That's the impression that I got, although I'm having a hard time getting it work right for pages with a .php extension. I used <meta http-equiv="Content-Type" content="application/xhtml+xml;" /> in the head, but that didn't work. I also tried using an .htaccess file with
AddType application/xhtml+xml .php in it, but that didn't work either. Checking the headers sent still showed as Content-Type: text/html



(Edited by Pugzly on 07-01-2005 19:32)

Tyberius Prime
Paranoid (IV) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 07-02-2005 16:43

how about calling header('Content-type: ...'); in php (and I believe it's spelled 'Content-type', lower case t)

Pugzly
Paranoid (IV) Inmate

From: 127.0.0.1
Insane since: Apr 2000

posted posted 07-02-2005 23:34

Dunno why I didn't think of that. That seems to send the correct header, although that now puts Firefox into whacky mode, causing it to display that page as XML.... gotta figure that one out.

poi
Paranoid (IV) Inmate

From: France
Insane since: Jun 2002

posted posted 07-02-2005 23:43

That's what I do on a site in XHTML1.1 :

code:
$encodingType = "utf-8";

$acceptXml = stristr( $_SERVER["HTTP_ACCEPT"], "application/xhtml+xml" );
if( $acceptXml  )
	header( "Content-type: application/xhtml+xml; charset=". $encodingType );
else
	header( "Content-type: text/html; charset=". $encodingType );

It works like a charm in IE, FF, OP.

Hope that helps,

HZR
Paranoid (IV) Inmate

From: Cold Sweden
Insane since: Jul 2002

posted posted 07-03-2005 00:11
quote:
I used <meta http-equiv="Content-Type" content="application/xhtml+xml;" /> in the head, but that didn't work.

That would have no effect since the parser must know how to parse it before seeing that meta element.

quote:
I also tried using an .htaccess file with AddType application/xhtml+xml .php in it, but that didn't work either.


I have no idea why, try again.

quote:
I believe it's spelled 'Content-type', lower case t


It's case insesitive.

quote:
That seems to send the correct header, although that now puts Firefox into whacky mode, causing it to display that page as XML


Then you're not sending it as application/xhtml+xml it seems. What content-type did you use?

quote:
That's what I do on a site in XHTML1.1 [some code]


That should really take q values into account.

And to answer your first question, Pugzly: as reisio said, use application/xhtml+xml. text/html is brain dead since there would be no advantage by using XHTML then. IMO, XHTML shouldn't be used on the web today (modulo if you're using content negotiation) since the client support is not satisfactory.

(Edited by HZR on 07-03-2005 00:17)

Pugzly
Paranoid (IV) Inmate

From: 127.0.0.1
Insane since: Apr 2000

posted posted 07-03-2005 03:29

I used, via a PHP header
header('Content-type: application/xhtml+xml;');

Checking the headers that are sent, it DOES send correctly. Here are the headers:

code:
Date: Sun, 03 Jul 2005 01:23:04 GMT
Server: Apache/1.3.31 (Unix) DAV/1.0.3 mod_gzip/1.3.26.1a mod_fastcgi/2.4.2 PHP/4.3.10 mod_ssl/2.8.19 OpenSSL/0.9.6c
X-Powered-By: PHP/4.3.10
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Content-Type: application/xhtml+xml;
Content-Encoding: gzip
Content-Length: 1050

200 OK



In Firefox, it shows up as an XML page, instead of just XHTML (like when I use text/html). In IE, I get the prompt to download the page (which would be correct - I'll fix that later).

FWIW, I ran the page through the WC3 validator, and it's valid XHTML 1.1 Transitional.

I've usually just used XHTML 1.0, which can be sent as text/html. But I'm starting to move to 1.1, and need to figure out what the hell is wrong.

Thanks for the help.

Pugzly
Paranoid (IV) Inmate

From: 127.0.0.1
Insane since: Apr 2000

posted posted 07-03-2005 04:15

Okay - I got it figured out. My <html> at the beginning of the document was
<html lang="EN">

which would validate. But when I changed it to
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">

the problem went away and the document is now correctly displayed. I also changed the Content-type to
header('Content-type: application/xhtml+xml;charset=iso-8859-1');

I did notice that once it's served as application/xhtml+xml, the & # 1 4 9 ; doesn't display at all (it does when served as text/html). I can resolve that.

I did notice that when I insert an XML declaration, I get an error. If I'm just serving up XHTML, and want to adhere to 1.1 Transitional, do I need an XML declaration?

HZR
Paranoid (IV) Inmate

From: Cold Sweden
Insane since: Jul 2002

posted posted 07-03-2005 11:32
quote:
I've usually just used XHTML 1.0, which can be sent as text/html.


XHTML 1.1 can also be sent as text/html of course. Both will make no sense.

quote:
I did notice that when I insert an XML declaration, I get an error.


What error? Please provide a URI.

quote:
If I'm just serving up XHTML, and want to adhere to 1.1 Transitional, do I need an XML declaration?


Apart from the fact that there's no such thing as XHTML 1.1 Transitional: no, the XML declaration is not mandatory.

(Edited by HZR on 07-03-2005 11:32)

Pugzly
Paranoid (IV) Inmate

From: 127.0.0.1
Insane since: Apr 2000

posted posted 07-03-2005 14:46
quote:

HZR said:
XHTML 1.1 can also be sent as text/html of course. Both will make no sense.



Yes, it COULD, but WC3 says "should not", and I like to play by the rules as much as possible.

quote:

HZR said:
What error? Please provide a URI.



I resolved this. It was an error because I had PHP short_open_tag enabled. Once I disabled that, the problem went away.

quote:

HZR said:
Apart from the fact that there's no such thing as XHTML 1.1 Transitional: no, the XML declaration is not mandatory.



You are correct. I mispoke. I'm using XHTML 1.1 - no Transitional.



Post Reply
 
Your User Name:
Your Password:
Login Options:
 
Your Text:
Loading...
Options:


« BackwardsOnwards »

Show Forum Drop Down Menu