Click here to get back home

content negotiation and parsing page contents

 HomeNewsGroups | Search | About
 comp.infosystems.www.authoring.html    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
content negotiation and parsing page contents wardy 02-06-2006
Posted by wardy on February 6, 2006, 11:43 am
Please log in for more thread options


I'm trying to undestand the impact of using content negotiation when
rendering my Web pages to various different browsers as I would like to
use the XHTML Strict DOCTYPE declaration. Reading the W3C guidelines,
if I render as 'text/html' then there are some backward compatibility
issues I need to worry about. Does this mean that the page must be
rendered in one way if I use the "application/xhmlt+xml" content type
and another if I use the "text/html" content type? This would mean
parsing of every page on the site.... Or, if I follow the backward
compatibility rules from the W3C, will it render properly regardless
of the content-type for a particular request?

Thanks


Posted by David Dorward on February 6, 2006, 2:35 pm
Please log in for more thread options


wardy wrote:

> I'm trying to undestand the impact of using content negotiation when
> rendering my Web pages to various different browsers as I would like to
> use the XHTML Strict DOCTYPE declaration. Reading the W3C guidelines,
> if I render as 'text/html' then there are some backward compatibility
> issues I need to worry about.

If you serve as text/html then some browsers will render the document in
ways you don't like (splattering the page with ">" characters whereever you
have an <img />, <br />, <hr /> and so on).

> Does this mean that the page must be rendered in one way if I use the
> "application/xhmlt+xml" content type and another if I use the "text/html"
> content type?

If it is served as text/html then it will be parsed with a tag soup slurper.

If it is served as application/xhtml+xml then it will be parsed with an XML
parser (which means IE will prompt user's to download it, and Firefox won't
render it until the entire document is downloaded and parsed, and will spit
errors at the user instead of trying to recover if the document isn't well
formed).

There are no differences in how browsers are supposed to render XHTML and
HTML (although there /are/ rules as to how CSS is applied which could
influence the rendering (e.g. class selectors are HTML only and don't apply
to XHTML, and the root element is <html> instead of <body>).

> This would mean parsing of every page on the site....

Browsers have to parse every page they display.

> Or, if I follow the backward compatibility rules from the W3C, will it
> render properly regardless of the content-type for a particular request?

No. At present, unless you have need of something that only XHTML can
provide on the client (like mixed-namespace documents), stick to HTML. (By
all means _write_ XHTML, but transform it to HTML before it gets to the
client).

The Mozilla FAQ states that the only reason application/xhtml+xml has a
higher quality value than text/html in the Accept request header, is so
that the browser will get MathML versions of documents. They advise the use
of HTML 4.01 Strict.

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is

Posted by Lachlan Hunt on February 6, 2006, 6:05 pm
Please log in for more thread options


David Dorward wrote:
> (e.g. class selectors are HTML only and don't apply to XHTML [...]).

Since when? Class selectors apply to any XML document in which the UA
has namespace specific knowledge of a class attribute. The spec
explicitly states that and goes on to provide examples of the SVG and
MathML class attributes, so there is no reason why they don't apply to
XHTML.

--
Lachlan Hunt
http://lachy.id.au/
http://GetFirefox.com/ Rediscover the Web
http://GetThunderbird.com/ Reclaim your Inbox

Posted by David Dorward on February 7, 2006, 3:16 am
Please log in for more thread options


Lachlan Hunt wrote:

> David Dorward wrote:
>> (e.g. class selectors are HTML only and don't apply to XHTML [...]).
>
> Since when?

Since CSS 2.

"For style sheets used with HTML"

-- http://www.w3.org/TR/CSS2/selector.html#class-html

> Class selectors apply to any XML document in which the UA
> has namespace specific knowledge of a class attribute.

Ah. I see they've changed that in CSS 2.1, thank goodness for that. Still a
working draft though.


--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is

Posted by wardy on February 8, 2006, 12:47 pm
Please log in for more thread options


Great....thanks for the info all. I thought that I had read that
rendering XHTML to MSIE as text/html actually invokes almost standards
mode, and not quirks/tag soup mode. Is that not correct?

When rendering XHTML as text/html, would I need to worry about putting
the meta tag for the content type if I am already setting this in th
headers on the server? I wouldn't think so, but then how do I indicate
to use a different charset than the default UTF-8 or UTF-16 designation
for a text/html page?

Thanks


Similar ThreadsPosted
XHTML 1.0 Content-Negotiation August 16, 2005, 5:00 pm
Apache Content negotiation with Chinese zh-TW and zh-CN August 4, 2006, 3:11 pm
Fixing a Table of Contents Menu, when contents Scroll May 5, 2008, 7:40 am
Update a web page with contents from another web page. January 8, 2005, 1:59 pm
Need help creating a "Click absolutely ANYWHERE on this page" link for an HTML page with no content February 7, 2007, 5:40 pm
css parsing order May 20, 2006, 8:11 pm
Parsing linefeeds correctly December 1, 2004, 7:53 pm
Best tool to convert html into XHTML for XML parsing? March 17, 2005, 1:15 am
Parsing error in Amaya HTML Editor January 28, 2008, 12:56 pm
How to periodically refresh content of my page? June 11, 2006, 7:51 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap