XSLT transformations work in IE and Stylus Studio but not in Firefox or Opera

We were developing some stylesheets to convert xml to html in Stylus Studio and had the problem that IE would render them fine, but when we used Firefox/Opera we only saw plain text.

If you are also experiencing this problem you are probably missing the xsl:output element:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html"/>

When the XSL processor sees this instruction it will generate a meta data element similar to the following in the resulting html header, which sets the content type to text/html. This lets the browser know to treat the resulting text as html:

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

The problem is - some XSL processors (e.g. Saxon ) appear to generate this meta data item even if the xsl:output is absent - by detecting the html tags in the document. It appears that the processor built into IE has this feature, so IE correctly interprets the html, even without the xsl:output. Firefox, however, does not.




You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

AddThis Social Bookmark Button

Leave a Reply