# HG changeset patch # User Paul Boddie # Date 1246922052 -7200 # Node ID abf35a8f5caa29cfb4e1a35a28efa87a0851e833 # Parent 7827d9adef8332ea99ad828420b984cc80f510af Added XHTML to HTML conversion for deficient browsers. diff -r 7827d9adef83 -r abf35a8f5caa XSLForms/Resources/WebResources.py --- a/XSLForms/Resources/WebResources.py Mon Jun 22 23:59:53 2009 +0200 +++ b/XSLForms/Resources/WebResources.py Tue Jul 07 01:14:12 2009 +0200 @@ -19,7 +19,7 @@ with this program. If not, see . """ -import WebStack.Generic +from WebStack.Generic import EndOfResponse, ContentType import XSLForms.Fields import XSLForms.Prepare import XSLForms.Output @@ -114,6 +114,7 @@ in_page_resources = {} init_resources = {} transform_resources = {} + document_resources = {} def clean_parameters(self, parameters): @@ -191,6 +192,22 @@ the optional 'references' to external documents. """ + # Provide support for deficient browsers like Internet Explorer. + + content_type = trans.content_type + + # NOTE: Introduce proper content type parsing into WebStack. + + accept = (trans.get_header_values("Accept") or [""])[0] + xhtml = "application/xhtml+xml" + + if content_type is not None and content_type.media_type == xhtml and accept.find(xhtml) == -1: + + # Get the conversion template. + + stylesheet_filenames.append(os.path.join(XSLForms.Prepare.resource_dir, "XHTMLToHTML.xsl")) + trans.set_content_type(ContentType("text/html", content_type.charset or trans.default_encoding)) + # Sanity check for the filenames list. if isinstance(stylesheet_filenames, str) or isinstance(stylesheet_filenames, unicode): @@ -346,7 +363,7 @@ self.init_document(trans, form) self.respond_to_document(trans, form) self.create_output(trans, form) - raise WebStack.Generic.EndOfResponse + raise EndOfResponse # Modular methods for responding to requests. @@ -444,7 +461,7 @@ else: encoding = trans.default_charset - content_type = content_type or WebStack.Generic.ContentType("application/xhtml+xml", encoding) + content_type = content_type or ContentType("application/xhtml+xml", encoding) trans.set_content_type(content_type) # Ensure that an output stylesheet exists. diff -r 7827d9adef83 -r abf35a8f5caa XSLForms/XSL/XHTMLToHTML.xsl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/XSLForms/XSL/XHTMLToHTML.xsl Tue Jul 07 01:14:12 2009 +0200 @@ -0,0 +1,8 @@ + + + + + diff -r 7827d9adef83 -r abf35a8f5caa XSLTools/XSLOutput.py --- a/XSLTools/XSLOutput.py Mon Jun 22 23:59:53 2009 +0200 +++ b/XSLTools/XSLOutput.py Tue Jul 07 01:14:12 2009 +0200 @@ -37,7 +37,7 @@ class Processor: """ - A handler which can prepare output for an XMLTools2 template. + A handler which can prepare output for an XSLForms template. """ def __init__(self, filenames, references=None, parameters=None, expressions=None):