Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IE9 and Chrome not rendering XML with XSL if XML is local and XSL is on remote server

I have the following XML:

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="http://www.test.com/AuditTrail.xsl"?>

and XSL:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <html>
        <head><title>Test</title></head>
    </html>
</xsl:stylesheet>

This works fine in IE8 but not in IE9 or Chrome. I have read that IE9 seems to prohibit loading XSL from a remote server if the XML source file is on the local machine. Is there any way to get IE9 and Chrome to apply a remote XSL file to a local XML file without messing with the security settings of the browsers? We have a desktop application that generates XML reports and displays them in a browser, transformed with stylesheets that are hosted on a remote server.

like image 667
TJF Avatar asked Jul 08 '11 16:07

TJF


1 Answers

Does this work locally? I do not think so because there are some errors in both XML and XSLT.

Chrome blocks local XML and XSLT processing! It is a issue or they disabled it for security reasons. Look at this Chrome Bug Report for some work-arounds.

IE9 disabled the support of mixture of local XML and remote XSLT. Also for security reasons! (I do not have a link for that)

Your XML needs to have at least one root element:

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="http://www.test.com/AuditTrail.xsl"?>
<hello/>

and your XSLT needs to have some XSLT templates:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
    <html>
    <head><title>Test</title></head>
    </html>
</xsl:template>

</xsl:stylesheet>

With this corrections this example will work for IE8 and Firefox.
In Chrome the XML and XSLT needs to be on a webserver. In IE9 both need to be on a webserver or locally stored (without mixture).

like image 138
therealmarv Avatar answered Jun 01 '23 23:06

therealmarv