8

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.)

4
  • 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! Commented Aug 9, 2011 at 15:16
  • @paulmoriss: Thanks for the (partial!) clarification. Sometimes in the morass of SE sites I get a bit lost ... Commented Aug 9, 2011 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. Commented Aug 10, 2011 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). Commented Aug 10, 2011 at 8:25

1 Answer 1

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.')));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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