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
Delivery ?
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:
PS! Put some strategic spacing in between suspicious variable names like $ _GET etc.
Different Way, Same Result
About 18 months ago, I attempted the same thing, Drupal and XML.
Updates
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
More Updates
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
Caching
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.
HTML Accept Sniffing and Caching (due to throttling)
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
Agreed
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.
Glad I Could Help
I'm glad someone someone could find it useful! (Sorry its so dated)
Solution
I finally found a workable way to make Drupal 4.6.3 serve XHTML and MathML. -
Chris Chiasson
IE blocked from your whole site and your link
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.
;-)
Working out the IE bugs
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
XML Declaration
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
I just rechecked your site - and it's still a "bug"
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:
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.
More Modifications
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
Early on ..
... was something I recommended. No web-developer should need to be without those, including the native FF DOM-inspector.
I use packetsniffers, though.
;-)
live-http-headers and problem resolution
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
I was able to see your site with IE6 earlier ...
.. 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.
;-)