Error loading stylesheet: An XSLT stylesheet does not have an XML mimetype

adler96

Member
Messages
117
Reaction score
2
Points
18
Hi!

I have a php file which produces xml. This xml file refers to an external xsl file. This xsl file includes an xsl stylesheet which is generated dynamically from a php file.

I am getting the following error (only in Firefox, the rest are working fine):
Error loading stylesheet: An XSLT stylesheet does not have an XML mimetype:

http://www.nightearth.com/common.php?get_translation_templates


That's it, the mime type of the php file is not being set correctly, even though at the beginning of my file I am including the lines:


<?
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
header("Content-type: text/xml");
?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:eek:utput method="html" encoding="UTF-8" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" />


So, basically what I need is that this php file will be evaluated, and at the same time it will be interpreted as an xsl stylesheet.

This code was working perfectly in other hostings, but for some reason it is not working fine here. I have tried modifying the .htaccess file, as suggested in different searches in Internet, but no result.

Any ideas?
 

essellar

Community Advocate
Community Support
Messages
3,295
Reaction score
227
Points
63
You are starting to send data (the echo statement) before setting the MIME-type header. If you put the header() statement first, you should fix the problem.

Note, though, that you may have some trouble with the MIME type in any case -- some user agents may be okay with "text/html", while others may demand "application/xml" (and others, notably IE, reject the notion of "application/xml" altogether on some sort of religious basis nobody has been able to make sense of).
 

adler96

Member
Messages
117
Reaction score
2
Points
18
That was it! Thanks a lot! :)

The solution makes total sense.

I know the proper mime type should be "application/xml", but I had to revert back to "text/xml" because of incompatibilites with Internet Explorer.


PS: Sorry for the double post. An error occurred while posting, so I posted the message again, but in the end both succeeded.
 
Top