The below is returned to the browser:
<?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="to_xhtml.xslt"?> <root> <value>test data</value> </root>
Chrome 7 and FF 5 do not appy the XSLT only showing the XML values. IE does apply the XSLT showing the resultant XHTML.
The XSLT file is there and is valid - I can proccess the XML locally and open the resulting XHTML in Chrome and Firefox...
The web server is IIS 6 and interface is PHP 5.3 if that has anything to with it?
<?xml version='1.0'?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml"> <xsl:output method='xml' indent='yes' doctype-public='"-//W3C//DTD XHTML Basic 1.1//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd"'/> <xsl:template match="/root"> <html> <head> <title> </title> </head> <body> <p> <xsl:value-of select="value"/> </p> ... </html>firefoxgoogle-chromexsltsafari
You need to ensure your page is served with the correct HTTP Content-Type header value in this case: text/xml, possible in PHP using the header function:
header('Content-type: text/xml'); echo $xmlStr;
*thanks to meder who lead me in the right direction for this.
Also In Chrome and Safari an error still occurs while applying the XSLT because of the above doctype-public value:
<xsl:output method='xml' indent='yes' doctype-public='"-//W3C//DTD XHTML Basic 1.1//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd"'/>;
It should be:
<xsl:output method="xml" indent="yes" doctype-public="-//W3C//DTD XHTML Basic 1.1//EN" doctype-system="http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd"/>
The doctype-public attribute should not even be looked at if doctype-system is not specfied according to the spec.
*thanks to LarsH for pointing out doctype-system should be in a separate value.
Regarding the doctype-public attribute: According to the spec,
The doctype-public attribute should be ignored unless the doctype-system attribute is specified.
So something's pretty fishy about your
<xsl:output-method> element, which has a doctype-public attribute but no doctype-system. (That doesn't excuse Chrome and Safari from "falling over" ... = crashing?)
Maybe you wanted
<xsl:output method="xml" indent="yes" doctype-public="-//W3C//DTD XHTML Basic 1.1//EN" doctype-system="http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd" />
See here for more about public and system identifiers in XML.
Apparently this is not the reason why Fx and Chrome wouldn't render your XML using XSLT (the content-type was the reason), but it's something you probably want to fix.