Hi All,

With the chameleon theme and the following modifications to chameleon.theme and common.inc, I have implemented a Drupal website that delivers functional XHTML+MathML, except for one big problem which I will detail below:

In common.inc I had to modify the drupal_get_html_head() function so the site wouldn't be totally broken for IE users.

In common.inc, I modified chameleon_page() to "properly" declare the file as XML, to give the SGML Doctype specification that I want (btw, does anyone know a way to do this with XML Schemas instead?), and to remove the XHTML-unsupported lang parameter.

So. The pages validate using the W3C validator:

The only problem is that they do not display correctly when viewed in Firefox. What's more, if one views the page source, copes it into a file, and then loads that file into Firefox, the MathML will render. Note that the local file trick works, with any file extension except the ones that automatically cause Firefox to assume the mime type is HTML. In other words, the source code from my pages could be copied into a file with no extension. They would load and display fine.

What do you think could be the cause(s) of this strange behavior? My guess would be that the site's PHP scripting system somehow does something to the browser that puts it in an HTML processing mode before it even begins processing the page.

How might the browser be caused to render the pages correctly?

I originally listed the code for my modifications, but the form would not accept "suspicious imput".

Comments

eldarin’s picture

Do you deliver MIMETYPE content as application/xhtml+xml to FireFox after useragent-sniffing ?

Use FireFox with the web-developer extension and the live-http-headers to see what is going on ...

If you try any static pages, you can update .htaccess with:

<IfModule mod_rewrite.c>
  RewriteEngine on
  # - Rewrite MIMETYPE served with STATIC FILE URLs for capable XML renderers
   AddType text/html .xhtml
   RewriteCond %{HTTP_ACCEPT} application/xhtml\+xml
   RewriteRule \.xhtml$ - [T=application/xhtml+xml]
</IfModule>

PS! Put some strategic spacing in between suspicious variable names like $ _GET etc.

Brian@brianpuccio.net’s picture

About 18 months ago, I attempted the same thing, Drupal and XML.

Chris Chiasson’s picture

I actually read your page a few beeks ago. It was very informative.

Also, I realized I have a new problem. Apparently, Firefox is not receiving the correct mime type if the user is not logged in. How is that possible (and why would the W3C have validated XHTML 1.1 page with a text/html mime type -- I'm pretty sure W3C didn't log in :-] )? - Chris Chiasson

Chris Chiasson’s picture

As far as I can tell, the wrong MIME type for Firefox was due to caching being enabled for anonymous users. I have fixed this problem by disabling the throttling module. The original problem of the MathML not displaying when rendered from the web remains. - Chris Chiasson

Brian@brianpuccio.net’s picture

I don't use caching myself, so I can't say how it will be effected by change of MIME with respect to user agent changes.

Chris Chiasson’s picture

Brian, the reason why caching could affect anonymous page rendering is that caching does not execute the scripts on each page. When I updated the scripts to do the "application/xhtml+xml sniffing", the site was probably still using the old script results (text/html) for anonymous page views. - Chris Chiasson

Brian@brianpuccio.net’s picture

I agree. I dont think that with the current way Drupal handles caching you cna selectively serve different MIME types based upon user agent. Best of luck in your MathML experiments, I'll be keeping an eye on your site for anything neat you come up with.

Brian@brianpuccio.net’s picture

I'm glad someone someone could find it useful! (Sorry its so dated)

Chris Chiasson’s picture

I finally found a workable way to make Drupal 4.6.3 serve XHTML and MathML. -
Chris Chiasson

eldarin’s picture

Following your link with IE makes IE attempt to save the page, as you don't properly serve the page as text/html MIMETYPE. This effectively blocks your entire site for IE users - i.e a lot of readers. That is a bit of a sub-optimal approach unless you strictly want to reserve viewing for XML-capable user-agents.

I would suggest delivering the page normally for IE and put a notice about missing plugin for MathML - and e.g refer to http://www.w3.org/Math/XSL/ which informs about various options and what MathML is.

Oh, another thing - the XML-declaration ahead of your DOCTYPE declaration will throw IE into quirks mode. So, then your entire boxing layout might change a lot, and you will have to employ many CSS hacks ...
There is abundant description about how IE strict-mode works on the MSDN website. They also specifically mentions that anything ahead of the DOCTYPE does throw it into quirks mode - unleashing a pandora's box of bugs.
;-)

Chris Chiasson’s picture

Eldarin: Funny, it doesn't presently do that in IE on my computer (or others') right now - *but it has done that before*. Are you the person that created the TestML account a while back? If so, I think the workaround is to switch themes on the server side and then to switch back. Obviously, that is a viable option for me, but not for anyone else. I wish I could figure out how the bug is triggered.
Chris Chiasson

Chris Chiasson’s picture

Actually, I think maybe it is the XML declaration that is throwing things off - I believe the server is sending the right headers (as per the code I posed earlier), but it always sends that XML declaration. I will try to make that conditional. - Chris Chiasson

eldarin’s picture

Looking at your site again, makes IE6 which I use try and save the page.

When it comes to clearing the cache, there are several issues which have been reported - and some fixed for Drupal 4.7 . Also take a look at the much needed logic to the caching system that Jeremy from kerneltrap.org added. I think it's even in use at drupal.org right now. ;-)

Besides, you should do like I said and put some proper declarations for IE - don't use the XML-trigger at first etc. Here is what you are serving to my poor untrusty IE6:

HTTP/1.1 200 OK
Date: Mon, 19 Sep 2005 xx:xx:xx GMT
Server: Apache/2.0.54 (Gentoo/Linux) FrontPage/5.0.2.2635 mod_ssl/2.0.54 OpenSSL/0.9.7e DAV/2 SVN/1.1.3 PHP/4.4.0
X-Powered-By: PHP/4.4.0
Expires: Sun, 19 Nov 1978 05:00:00 GMT
Last-Modified: Mon, 19 Sep 2005 xx:xx:xx GMT
Cache-Control: no-store, no-cache, must-revalidate
Cache-Control: post-check=0, pre-check=0
Pragma: no-cache
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html; charset=utf-8

<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">

No wonder IE has a rough time with this ... just take a look at the DOCTYPE itself ..
;-)

I guess you forgot about it when hacking the headers.

Chris Chiasson’s picture

Eldarin, I changed the headers some more (and updated the post to reflect them). Is the problem fixed? BTW, how did you get that display of the connection? I know how to view page source, but it would really help me if I could view the entire "session". Thank you. - Chris Chiasson

eldarin’s picture

Use FireFox with the web-developer extension and the live-http-headers to see what is going on ...

... was something I recommended. No web-developer should need to be without those, including the native FF DOM-inspector.

I use packetsniffers, though.
;-)

Chris Chiasson’s picture

Eldarin: Yea, I reinistalled FF Beta 1 and looked at the DOM stuff, but I couldn't figure it out in the time I spent on it. I will have to go back and check again. (maybe live-http-headers is an extension - will follow up later) Btw, did my changes clear up the IE problem? - Chris Chiasson

eldarin’s picture

.. after you had corrected the DOCTYPE.

Live HttpHeaders is an extension, yes. Be sure to get the "Web Developer" extension as well !

BTW you will probably find much more competent help on forums like http://www.webmasterworld.com/ when it comes to generic webdesign.
;-)