Chrome可以在本地文件上执行XSL转换吗? [英] Can Chrome be made to perform an XSL transform on a local file?

查看:124
本文介绍了Chrome可以在本地文件上执行XSL转换吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



然而,当我将文件中的xml和xsl保存并尝试在本地打开它们时,Chrome浏览器将不会执行xsl转换。它只是显示一个空白页面。



我添加了<?xml-stylesheet type =text / xslhref =style。 xsl> 标签添加到xml文档中,并且firefox按照它的外观呈现它。另外,如果我通过Web服务器查看这些文件,chrome会显示它应该查看的文件。



是否chrome在查找样式表信息时遇到问题当链接是本地?将href更改为 file:/// C:/xsl/style.xsl 没有任何区别。



更新:这似乎是安全策略的一个副作用不会将file:/// *视为同一来源这会导致以下错误出现在控制台中:


不安全的尝试从以下URL文件加载URL文件:/// C:/xsl-rpg/style.xsl:/// C:/xsl-rpg/data.xml。域,协议和端口必须匹配。


解决方案

简短的回答是否,使用多种浏览器在那里。 p>

原因不起作用是由于Chrome以有争议的方式解决安全问题。 [1] [2] [3] [4] 通过阻止XML文件访问同一目录中的本地XSLT文件,而HTML文件可以访问同一目录中的.CSS文件。



在引用的所有问题中以上,用户要求更清楚的错误消息e(因为域,协议和端口实际上匹配),或者至少在没有样式的情况下显示XML。 Chrome开发者已经忽略了这些请求。


I was looking into xslt and started testing with the examples on w3schools.

However, when I save the xml and xsl in files and try opening them locally, chrome won't perform the xsl transform. It just shows a blank page.

I have added the<?xml-stylesheet type="text/xsl" href="style.xsl"> tag to the xml document, and firefox renders it as it is supposed to look. Also, if I look at the files through a web server, chrome displays the file as it is supposed to look.

Is it that chrome has a problem finding the stylesheet information when the link is local? Changing the href to file:///C:/xsl/style.xsl didn't make any difference.

Update: This seems to be a side effect of a security-policy to not treat file:///* as same origin. This makes the following error appear in the console:

Unsafe attempt to load URL file:///C:/xsl-rpg/style.xsl from frame with URL file:///C:/xsl-rpg/data.xml. Domains, protocols and ports must match.

解决方案

The short answer is "No, use one of the diverse set of browsers out there".

The reason this doesn't work is due to a security concern that Chrome has addressed in a controversial way[1][2][3][4], by blocking XML files from accessing local XSLT files in the same directory, while HTML files can access .CSS files in the same directory just fine.

Across the issues cited above, users have asked for a clearer error message (since the domains, protocols and ports do in fact match), or at least displaying the XML without the styling. Chrome developers have ignored these requests.

这篇关于Chrome可以在本地文件上执行XSL转换吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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