IE9和Chrome如果XML本地且XSL位于远程服务器上,则不会使用XSL呈现XML [英] IE9 and Chrome not rendering XML with XSL if XML is local and XSL is on remote server

查看:97
本文介绍了IE9和Chrome如果XML本地且XSL位于远程服务器上,则不会使用XSL呈现XML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下XML:

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

和XSL:

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

在IE8中可以正常工作,但在IE9或Chrome中无法正常工作。我已经读过,如果XML源文件在本地机器上,IE9似乎禁止从远程服务器加载XSL。
有什么办法让IE9和Chrome浏览器将远程XSL文件应用到本地XML文件,而不会影响浏览器的安全设置?
我们有一个桌面应用程序,用于生成XML报告并将其显示在浏览器中,并使用托管在远程服务器上的样式表进行转换。 解决方案

这是否可以在本地使用?我不这么认为,因为XML和XSLT都存在一些错误。



Chrome阻止本地XML和XSLT处理!这是一个问题,或者出于安全考虑而被禁用。查看此 Chrome Bug Report 以了解一些变通办法。



IE9禁止混合使用本地XML和远程XSLT。也出于安全原因! (我没有链接)



您的XML需要至少有一个根元素:

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

并且您的XSLT需要一些XSLT模板:

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

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

< / xsl:stylesheet>

通过此更正,此示例将适用于IE8和Firefox。

在Chrome XML和XSLT需要位于Web服务器上。在IE9中都需要在网络服务器上或本地存储(不含混合)。

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.

解决方案

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

这篇关于IE9和Chrome如果XML本地且XSL位于远程服务器上,则不会使用XSL呈现XML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆