Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I run a forum which serves its pages as XHTML+MathML+SVG; in full:

<!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-flat.dtd">

Using the MathPlayer plugin, Internet Explorer users can use this site. However, sometimes someone is using the forum from IE and isn't able to install MathPlayer (maybe they're on a public machine somewhere). Then IE (at least 6&7) complains about the XHTML and offers just to download the file.

I read on the w3c site how to get around this using an XSL transformation (http://www.w3.org/MarkUp/2004/xhtml-faq#ie). When I put this in place, I found that Chrome was now complaining vociferously about undefined entities (the specific one was &nbsp; but testing shows that that's not relevant).

Bizarrely, I can get round this by manually declaring the entities in the DOCTYPE:

<!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-flat.dtd" [
<!ENTITY nbsp "&#160;">
]>

but I'd rather not do this for the whole gamut of entities possible. I say "bizarrely" because the XHTML+MathML+SVG dtd does, as far as I can see, declare these entities. So somehow these are getting missed out.

Is there a way around this problem? Can I serve XHTML-with-entities to IE?

In case it matters, the pages are generated by a php script and are served via apache, so if there's a reliable method of sniffing the browser and modifying the start of the document (so only sending the <?xml-stylesheet ...> bit to IE) then that would be an acceptable alternative.

(I hope I have the right SE site ... please let me know if I'm in the wrong place. Ditto with the tags.)

share|improve this question
    
Pure (X)HTML/CSS questions belong on stackoverflow.com, but yours isn't so straightforward, as you mention a possible server side solution, so I'm not flagging it for moving. If you don't get any answer here then I'd delete it and put it on there. Some HTML questions tend to get answered in seconds! –  paulmorriss Aug 9 '11 at 15:16
    
@paulmoriss: Thanks for the (partial!) clarification. Sometimes in the morass of SE sites I get a bit lost ... –  Loop Space Aug 9 '11 at 18:16
    
Rereading my comment, I may not be very clear. I mean "if I were you, I'd delete it...". It's up to you. –  paulmorriss Aug 10 '11 at 7:59
    
@paulmoriss: It is a server-side configuration issue since it's about coping with a browser that can't handle XHTML and how to send them something that they can cope with. Scanning the list of "related" questions, there seem a lot that are similar in idea. But I don't know what the scope of this site is (and the more I read, the more confused I get) and I haven't had any answers, so I'll follow your advice (in a little while). –  Loop Space Aug 10 '11 at 8:25

1 Answer 1

[I]f there's a reliable method of sniffing the browser and modifying the start of the document (so only sending the bit to IE) then that would be an acceptable alternative.

This PHP statement will match any browsers which include "MSIE" in the user agent string and you could refine the criteria by adding a version number, if desired:

$flag_is_ie = (false !== strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE'));

... with version numbers:

$flag_is_ie = (false !== strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 6.'));
$flag_is_ie = ( $flag_is_ie || (false !== strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 7.')));
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.