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

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

问题描述

我正在研究 xslt 并开始使用 w3schools 上的示例进行测试.

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

但是,当我将 xml 和 xsl 保存在文件中并尝试在本地打开它们时,chrome 不会执行 xsl 转换.它只显示一个空白页面.

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.

我已将<?xml-stylesheet type="text/xsl" href="style.xsl"> 标签添加到 xml 文档中,firefox 会按预期呈现它看.此外,如果我通过网络服务器查看文件,chrome 会按预期显示文件.

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.

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

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.

更新:这似乎是安全政策的副作用 不将 file:///* 视为同源. 这使控制台中出现以下错误:

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:

尝试从带有 URL file:///C:/xsl-rpg/data.xml 的框架加载 URL file:///C:/xsl-rpg/style.xsl 是不安全的.域、协议和端口必须匹配.

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

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

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.

在上述问题中,用户要求更清晰的错误消息(因为域、协议和端口实际上匹配),或者至少显示没有样式的 XML.Chrome 开发者忽略了这些请求.

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天全站免登陆