可以讓 Chrome 對本地文件執行 XSL 轉換嗎? - Can Chrome be made to perform an XSL transform on a local file?

問題:

I was looking into xslt and started testing with the examples on w3schools.我正在研究 xslt 並開始使用 w3schools 上的示例進行測試。

However, when I save the xml and xsl in files and try opening them locally, chrome won't perform the xsl transform.但是,當我將 xml 和 xsl 保存在文件中並嘗試在本地打開它們時,chrome 不會執行 xsl 轉換。 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.我已將<?xml-stylesheet type="text/xsl" href="style.xsl">標記添加到 xml 文檔中,firefox 將其呈現爲它應有的樣子。 Also, if I look at the files through a web server, chrome displays the file as it is supposed to look.此外,如果我通過 Web 服務器查看文件,chrome 會按預期顯示文件。

Is it that chrome has a problem finding the stylesheet information when the link is local?是不是chrome在本地鏈接時查找樣式表信息有問題? Changing the href to file:///C:/xsl/style.xsl didn't make any difference.將 href 更改爲file:///C:/xsl/style.xsl沒有任何區別。

Update: This seems to be a side effect of a security-policy to not treat file:///* as same origin.更新:這似乎是不將 file:///* 視爲同源的安全策略的副作用 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.不安全的嘗試從帶有 URL file:///C:/xsl-rpg/data.xml 的框架加載 URL file:///C:/xsl-rpg/style.xsl。 Domains, protocols and ports must match.域、協議和端口必須匹配。


解決方案:

參考: https://stackoom.com/en/question/G44Q
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章