How to change MIME type to application/xhtml+xml ?
How to change MIME type to application/xhtml+xml ?
My blog at http://dieweltistgarnichtso.net/ identifies itself as text/html page. However, that limits me in embedding correct XHTML in posts, since browsers like Firefox parse the site as HTML.
How can i change the given MIME type to application/xhtml+xml ?
How can i change the given MIME type to application/xhtml+xml ?
Re: How to change MIME type to application/xhtml+xml ?
Your template's index.tpl should contain a line like:erlehmann wrote:How can i change the given MIME type to application/xhtml+xml ?
Code: Select all
<meta http-equiv="Content-Type" content="text/html; charset={$head_charset}" />YL
Re: How to change MIME type to application/xhtml+xml ?
I was of the impression that S9Y outputs XHTML. The W3C validator thinks that, too.yellowled wrote:However, the Content-Type for html files (as far as I know) is always supposed to be "text/html" - what's your source for this being wrong?
Re: How to change MIME type to application/xhtml+xml ?
Yes, that's true. But that doesn't require changing the Content-Type (again, as far as I know).erlehmann wrote:I was of the impression that S9Y outputs XHTML. The W3C validator thinks that, too.yellowled wrote:However, the Content-Type for html files (as far as I know) is always supposed to be "text/html" - what's your source for this being wrong?
It's also true that you get some validation errors for your blog, but that's not very likely because of the different Content-Type but because of some XHTML errors in your posts. Let's see ...
Okay, first of all, your index.tpl is missing an xmlns attribute. In that file, edit the <html> line like this:
Code: Select all
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="{$lang}" lang="{$lang}">YL
Re: How to change MIME type to application/xhtml+xml ?
It does; simply because browsers parse it as HTML otherwise. HTML has no namespace feature and isn't necessarily well-formed, so i can't embed XML, Javascript makes problems, too - in XHTML it must be masked as CDATA. In the end, I like XHTML better, it's simpler for most purposes and hasn't that many quirks.yellowled wrote:Yes, that's true. But that doesn't require changing the Content-Type (again, as far as I know).erlehmann wrote:I was of the impression that S9Y outputs XHTML. The W3C validator thinks that, too.
I'm working on this. Since the XHTML engine wasn't triggered, I didn't notice it at first.It's also true that you get some validation errors for your blog, but that's not very likely because of the different Content-Type but because of some XHTML errors in your posts.
How come ? I though both was correct ...Second, you have some tags in your source code which are not not valid XHTML - i.e. it's <br />, not <br/> (note the white space character).
Nope, I write code the old-fashioned way.Are you using a WYGIWYS editor? Which one?
-
garvinhicking
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Re: How to change MIME type to application/xhtml+xml ?
Hi!
You can emit XHTML with a simple html Content-Type, browser's accept this.
Forcing an xhtml content-type header will make the site unparsable in case an error occurs. A simple "<br>" will lead to the WHOLE SITE not being displayed.
This is the reason why Serendipity does not use XHTML as the content-type.
You can emit that on your own if you edit/create a template'S config.inc.php and use:
However, I don't recommend that. No good comes from it.
Regards,
Garvin
You can emit XHTML with a simple html Content-Type, browser's accept this.
Forcing an xhtml content-type header will make the site unparsable in case an error occurs. A simple "<br>" will lead to the WHOLE SITE not being displayed.
This is the reason why Serendipity does not use XHTML as the content-type.
You can emit that on your own if you edit/create a template'S config.inc.php and use:
Code: Select all
header('Content-Type: application/xhtml+xml; charset=UTF-8');
Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Re: How to change MIME type to application/xhtml+xml ?
I can't really tell you why this is, but it iserlehmann wrote:How come ? I though both was correct ...Second, you have some tags in your source code which are not not valid XHTML - i.e. it's <br />, not <br/> (note the white space character).
Very good, because in my humble opinion it's the only sane way to go if you want valid XHTML outputerlehmann wrote:Nope, I write code the old-fashioned way.Are you using a WYGIWYS editor? Which one?
YL
Re: How to change MIME type to application/xhtml+xml ?
W3C validator accepts it, apparently. I also couldn't locate anything in the XHTML spec.yellowled wrote:I can't really tell you why this is, but it iserlehmann wrote:How come ? I though both was correct ...Second, you have some tags in your source code which are not not valid XHTML - i.e. it's <br />, not <br/> (note the white space character).XHTML is much more strict in terms of cases and closing tags correctly.
They accept this as HTML, which means: No namespaces and possibly javascript errors.garvinhicking wrote:You can emit XHTML with a simple html Content-Type, browser's accept this.
I want that behaviour, so I can make my site standards compliant.Forcing an xhtml content-type header will make the site unparsable in case an error occurs. A simple "<br>" will lead to the WHOLE SITE not being displayed.
If you'd use it, errors in plugins would be noticed way sooner, wouldn't they ?This is the reason why Serendipity does not use XHTML as the content-type.
Aside of that I will be forced to write correct XHTML, any other problems ?However, I don't recommend that. No good comes from it.
-
garvinhicking
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Re: How to change MIME type to application/xhtml+xml ?
Hi!
User Input is the evil thing: Nobody prevents users from typing "<br>" in their boxes, no one prevents them from invalidly nesting Elements. There is no easy way to make sure that the user input on a page is always XHTML valid.
Regards,
Garvin
Serendipitys Code is not the problem, it can be easily made XHTML compliant.If you'd use it, errors in plugins would be noticed way sooner, wouldn't they ?
User Input is the evil thing: Nobody prevents users from typing "<br>" in their boxes, no one prevents them from invalidly nesting Elements. There is no easy way to make sure that the user input on a page is always XHTML valid.
I can't really tell, my personal bottom line as always that the application/xhtml+xml was never required. You mentioned that namespaces cannot be used. What exactly do you mean? Which kind of errors do you get, when a document has text/html as content-type instead of application/xhtml+xml, when the content of the document is the same?Aside of that I will be forced to write correct XHTML, any other problems ?
Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Re: How to change MIME type to application/xhtml+xml ?
Well, check it against the XHTML DTD on submission ? I do a (simple) web app and we do exactly that - although our DTD is slimmed down to only include semantic elements.garvinhicking wrote:User Input is the evil thing: Nobody prevents users from typing "<br>" in their boxes, no one prevents them from invalidly nesting Elements. There is no easy way to make sure that the user input on a page is always XHTML valid.
XML has Namespaces, HTML hasn't. What is unclear about that ?You mentioned that namespaces cannot be used. What exactly do you mean?
The embedding of Javascript is different between HTML and XHTML - as far as I am aware, user agents have hickups there. for XHTML it isWhich kind of errors do you get, when a document has text/html as content-type instead of application/xhtml+xml, when the content of the document is the same?
Code: Select all
<script type="text/javascript">
<![CDATA[
// here be Javascript
]]>
</script>
-
garvinhicking
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Re: How to change MIME type to application/xhtml+xml ?
Hi!
Sadly I don't have konqueror at my hands, so I cannot test the CDATA stuff. Other browsers do interpret CDATA with HTML mimetype as well, so I'm not sure who is misbehaving there. IMHO the content-type should always only be a type hint, not a type restriction -the content should matter..?
Regards,
Garvin
Simple user's don't understand semantics. All they want to do is blog and type. Putting them on validation restrictions is not productive.Well, check it against the XHTML DTD on submission ? I do a (simple) web app and we do exactly that - although our DTD is slimmed down to only include semantic elements.
Sadly I don't have konqueror at my hands, so I cannot test the CDATA stuff. Other browsers do interpret CDATA with HTML mimetype as well, so I'm not sure who is misbehaving there. IMHO the content-type should always only be a type hint, not a type restriction -the content should matter..?
Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Re: How to change MIME type to application/xhtml+xml ?
Look, those who can't even bother to learn some simple rules should probably not use tools like (X)HTML; it only makes life worse for the rest of us.garvinhicking wrote:Simple user's don't understand semantics. All they want to do is blog and type. Putting them on validation restrictions is not productive.
XHTML rules are really simple, way simpler than HTML rules. And you say those who want to use it shouldn't abide by that rules ? Well, humanity did well along centuries without markup, then those lazy-asses can too, don't you think so ?
So ... what is the browser supposed to do on a page of unclear type ?IMHO the content-type should always only be a type hint, not a type restriction -the content should matter..?
A: Parse it as "tag soup" (read: HTML). Ditch XHTML features.
B: Parse it as XHTML. Preserve XHTML features. Markup errors are fatal.
I like the second much more, probably because I know what I am doing. And every (other) markup / programming language requires that to some extent.
Please note the following:
- In XHTML: <![CDATA[...]]> is a CDATA section. In HTML, it's a bogus comment. Actually, XHTML allows the use of CDATA sections, HTML does not.
- XHTML allows non XHTML elements and attributes (in different namespaces) to be used, HTML does not. Actually, HTML permits no external namespaces.
Best Regards, Summer Glau
P.S.: Don't forget to read Ian Hickson's take on the subject matter.
-
garvinhicking
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Re: How to change MIME type to application/xhtml+xml ?
Hi!
I believe the best way for you is to achieve this with a custom template (or plugin, if you prefer) that simply issues the PHP header() call.
As for Serendipity, as long as browsers make a full page fail to render when markup errors occur, it is not good (read: beneficial for the common end-user) to use the xhtml+xml mimetype.
If you prefer a patch to the s9y core to support the selection of the mimetype as a config option, we can gladly integrate this!
Regards,
Garvin
I believe the best way for you is to achieve this with a custom template (or plugin, if you prefer) that simply issues the PHP header() call.
As for Serendipity, as long as browsers make a full page fail to render when markup errors occur, it is not good (read: beneficial for the common end-user) to use the xhtml+xml mimetype.
If you prefer a patch to the s9y core to support the selection of the mimetype as a config option, we can gladly integrate this!
Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Re: How to change MIME type to application/xhtml+xml ?
You should know what the spec says - and for all purposes of rendering a) XHTML with type text/html is actually HTML (see appendix C of the XHTML spec) and b) fail is there because you just can't guess, there are over 9000 possibilities in each case.garvinhicking wrote:As for Serendipity, as long as browsers make a full page fail to render when markup errors occur, it is not good (read: beneficial for the common end-user) to use the xhtml+xml mimetype.
Look at XHTMLMIME, which says:
With your stand on the matter, it will never be possible to actually call S9Y output XHTML, simply because XML features cannot be used that way.In summary, 'application/xhtml+xml' SHOULD be used for XHTML Family documents, and the use of 'text/html' SHOULD be limited to HTML-compatible XHTML 1.0 documents.
Would be very nice. Am I expected to write this (i have no idea of S9Ys inner workings - would take a while) or will someone else do (because it probably is only a minor thing) ?If you prefer a patch to the s9y core to support the selection of the mimetype as a config option, we can gladly integrate this!
-
garvinhicking
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Re: How to change MIME type to application/xhtml+xml ?
Hi!
Current templates focus on usability and compatibility instead of pedantic semantics

Regards,
Garvin
Those pedantic enough that feel the need to do so, can do so with their own templates.With your stand on the matter, it will never be possible to actually call S9Y output XHTML, simply because XML features cannot be used that way.
Current templates focus on usability and compatibility instead of pedantic semantics
No one expects this of you! To me personally, the matter is not interesting yet because of the choking browser behavior on non-validating XHTML documents. I'm all for "ultra liberal HTML parsing".Would be very nice. Am I expected to write this (i have no idea of S9Ys inner workings - would take a while) or will someone else do (because it probably is only a minor thing) ?
Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/