On Jul 4, 2009, at 6:03 AM, dlypka wrote: > > The browser can simply indicate the desired format in its request. > If it wants XHTML, it can simply ask for it explicitly. > So web2py can just check the type and serve as requested. > All that may be needed is to devise a new protocol for requesting the > format.
Most browsers these days are happy with most of the normal formats. I think I can boil down the issues I'm talking about to two things. 1. The browser should actually be returning what it's advertising in its doctype. In the case of xhtml, this *requires* that the content validate against the relevant DTD. 2. The format of the content is indicated to the browser in (at least) three ways: the http content-type header, supplied by the server; the DOCTYPE in the document (if it's there), and possibly a content-type meta tag. As it happens, the browser pays attention only to the first of those three. web2py advertises xhtml in its DOCTYPE and html in the meta tag, which is a contradiction that doesn't matter, because the browser actually obeys the server, which says html in the content-type http header. web2py actually serves invalid (not very invalid, but this is an all or nothing test) xhtml, but is saved by the fact that the server is claiming that it's actually html, which persuades the browser to be tolerant of invalid content. > > On Jul 4, 1:59 am, Jonathan Lundell <jlund...@pobox.com> wrote: >> On Jul 3, 2009, at 8:20 PM, mdipierro wrote: >> >> >> >>> You clearly know about this more than I do. >> >> I'm hoping there are people on this list who know more than either of >> us. >> >>> For legacy issues we cannot change the content-type: text.html but >>> we >>> can change the <!DOCTYPE> in the scaffolding app. >> >> I ask only out of curiosity: who's relying on the content-type? (Are >> we talking about the meta tag here?) >> >> Another question: why do I see xhtml strict on the example page >> <http://www.web2py.com/examples/spreadsheet >> >, but xhtml transitional when I run web2py locally? >> >>> As long as there are no major objections I say we should follow your >>> advice. >>> I look forward to your html patches. ;-) >> >> I have the glimmerings of an idea.... >> >> >> >> >> >>> Massimo >> >>> On Jul 3, 9:19 pm, Jonathan Lundell <jlund...@pobox.com> wrote: >>>> By way of background, web2py generates xhtml pages, with these >>>> doctypes (I'm not clear on why one or the other is chosen; perhaps >>>> someone could enlighten me): >> >>>> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" >>>> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd >>>> "> >>>> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" >>>> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd >>>> " >> >>>> The problem is, web2py's xhtml is not, by and large, valid. This >>>> ought >>>> to cause a problem, because xhtml parsers aren't allowed to handle >>>> invalid markup. We get away with it because essentially all servers >>>> present our pages as html, not xhtml, and our browsers parse it as >>>> html, which is more forgiving. >> >>>> (One of the better explanations of all this is: >>>> <http://webkit.org/blog/2006/09/20/understanding-html-xml-and-xhtml/ >>>> >.) >> >>>> Here's an illustration. With a standards-compliant browser (I'm >>>> using >>>> Safari 4.0.1 and Firefox 3.5 on OS X), have a look at these pages: >> >>>> http://www.web2py.com/examples/spreadsheethttp://lobitos.net/w2p/w2p >>>> .... >> >>>> They're identical (I copied the first one, changing only some >>>> URLs to >>>> be absolute instead of relative). You should see that your browser >>>> won't display the third version. >> >>>> Why? Because the first two are served as "Content-Type: text/html", >>>> while the third is served as "Content-Type: application/xhtml+xml". >>>> This is how Apache handles .html and .xhtml files by default. >>>> Notice >>>> that the browser pays attention to the Content-Type header and >>>> ignores >>>> the DOCTYPE (the w3 validator looks at DOCTYPE, though). Notice >>>> also >>>> that the browser is ignoring the "<meta http-equiv="content-type" >>>> content="text/html; charset=utf-8" />" line; it really does believe >>>> the http header: not the doctype, not the meta. >> >>>> So. Why use the XHTML DOCTYPE? The main reason that I can think >>>> of is >>>> that the resulting document, if valid, has a DTD and can be >>>> parsed as >>>> XML. Not by the browser, which is going to parse it as bad html, >>>> but >>>> by someone else, maybe. But that reason only holds water if the >>>> document is actually *valid* xhtml. >> >>>> (Another note: this is the spreadsheet application, but the same >>>> thing >>>> would happen with many, perhaps most, web2py pages, certainly any >>>> with >>>> <form action="">. You can try the same experiment with other >>>> pages.) >> >>>> What to do? In my view, there's a short-term answer and a long-term >>>> answer. And they're both complicated by legacy compatibility >>>> issues, >>>> which I'll take the liberty of ignoring here. >> >>>> In the short term, fix the output to be valid XHTML. This is easier >>>> if >>>> you use transitional rather than strict. >> >>>> In the long term, move to HTML. Given that it looks like XHTML2 has >>>> been abandoned, the future standard is going to be HTML5. Not very >>>> soon, since browsers are only starting to support it, and the FSM >>>> only >>>> knows when Microsoft will get around to it, but eventually, since >>>> HTML5 has a lot of nifty features. >> >>>> Me, I've settled on HTML4 Transitional for anything I've got >>>> control >>>> over, using XHTML only for a couple of pages that I need to parse >>>> as >>>> XML. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---