SitePoint Sponsor

User Tag List

Results 1 to 12 of 12
  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2004
    Location
    in my head
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    XHTML: correct MIME, won't validate

    Hi All,

    I have been trying to make the leap and go for XHTML 1.0 Strict, relatively pain free so far.

    I have been using the code:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
    <meta http-equiv="content-type" content="application/xhtml+xml; charset=utf-8" />

    <meta http-equiv="content-language" content="en" />

    W3C validates it OK as strict but says the content type is text/html, clearly I have not coded that, is there something I need to do on the server to make this happen?

    I thought that IE6 wouldn't display an XHTML page with the MIME type set to xhtml+xml......but mine does........code problem ?

    Help very much appreciated as I can't blow another "work" day trying to solve this as of yet "academic" problem.

    Cheers

  2. #2
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You cannot set the MIME type with a META element, sorry. It needs to be sent from the server, since a user agent needs this information before it starts parsing the document.

    See Doctype declaration and Content-Type headers for more info.
    The Content-Type header says that it's XML, and the XHTML namespace in the <html> tag tells the user agent that it is actually XHTML.
    Birnam wood is come to Dunsinane

  3. #3
    SitePoint Enthusiast
    Join Date
    Nov 2004
    Location
    in my head
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    lmao,

    I actually have that page bookmarked, very good read and enjoyed the reading position, very conversational and experience based, also, harangue is so under utilised as word.

    I have created a MIME type under the HTTP headers tab in IIS using the following details:

    Associated extension: .asp
    Content type (MIME): application/xhtml+xml

    The W3C validator is still saying its content type is text/html......

    Any more suggestions or pointers?

    Cheers

  4. #4
    bronze trophy
    Join Date
    Dec 2004
    Location
    Sweden
    Posts
    2,670
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    <% Response.ContentType = "application/xhtml+xml" %>
    Simon Pieters

  5. #5
    SitePoint Enthusiast
    Join Date
    Nov 2004
    Location
    in my head
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    thanks for the reply, I have tried that code and it works fine for FF, totally naffs IE, which is exactly what I expected.

    I even went as far as to include a content negotiation function which sets the MIME type dependant on the presence of application/xhtml+xml in the HTTP_ACCEPT string, I got unexpected results.

    Thought when I validated at w3c with each browser using verbose options that I would get a different message for the content-type, however, both now report text/html, despite having a function that changes the MIME type.

    Is this a false negative from w3c or have I expected / done the wrong thing.

    Cheers

  6. #6
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The W3C validator does not send 'application/xhtml+xml' in its Accept header, so you'll need to cater separately for it if you want to serve it XHTML.

    (The validator is independent from the user agent used for accessing it; it's a user agent of its own.)
    Birnam wood is come to Dunsinane

  7. #7
    SitePoint Enthusiast
    Join Date
    Nov 2004
    Location
    in my head
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So this is actually a false negative then from W3C?

    If they sent full MIME information then my ASP script would correctly detect and set the content type accordingly.

    Is it safe to say then that FF is rendering the page as "true" xhtml and IE is getting the hotly debated "text/html" version of my xhtml page?

    Could you point me to any resources that demonstrate how to cater for W3C, I would like to develop pages and then check them for xhtml compliance, would be nice if I didn't have to do too many daft steps to make this happen.

    Cheers

  8. #8
    bronze trophy
    Join Date
    Dec 2004
    Location
    Sweden
    Posts
    2,670
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    A user agent is not required to send any Accept headers.
    If no Accept header field is present, then it is assumed that the client accepts all media types.
    http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html

    You could use query parameters: ?type=xml and ?type=html, or something equivalent.
    Simon Pieters

  9. #9
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What happens if an IE user goes to the page with "?type=xml"?
    We miss you, Dan Schulz.
    Learn CSS. | X/HTML Validator | CSS validator
    Dynamic Site Solutions
    Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.

  10. #10
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    They will be asked if they want to download the page.
    Birnam wood is come to Dunsinane

  11. #11
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    *chuckles*

    I guess I should have added "(Rhetorical question.)" to the end.
    We miss you, Dan Schulz.
    Learn CSS. | X/HTML Validator | CSS validator
    Dynamic Site Solutions
    Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.

  12. #12
    Robert Wellock silver trophybronze trophy xhtmlcoder's Avatar
    Join Date
    Apr 2002
    Location
    A Maze of Twisty Little Passages
    Posts
    6,316
    Mentioned
    60 Post(s)
    Tagged
    0 Thread(s)
    Basically ["HTTP_USER_AGENT"],"W3C_Validator" is the W3C Validator.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •