本文介绍了样式表中的xsl:import和xsl:include在Google Chrome上不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在建立一个使用xsl样式表的网站,并且在其他样式表导入的util样式表中建立了一个有用的函数小型库

I'm building a website that uses xsl stylesheets, and I'm building up a small library of useful functions in a util stylesheet that other sheets import with

<xsl:import href="util" />

在每张纸的顶部.这在Google Chrome中不起作用,因为它还不支持xsl:import.有人可以给我写一个我可以在服务器端运行的样式表,该样式表将读取xsl:import行并在将其发送给客户端之前导入相关的样式表吗?

at the top of every sheet. This doesn't work in Google Chrome, as it doesn't support xsl:import yet. Can someone please write me a stylesheet that I can run on the server side that will read the xsl:import line and import the relevant stylesheet before its sent to the client?

推荐答案

我会做以下类似的事情,它将结合样式表服务器端,然后再使用Chrome.第一步就位了,因为xsl:import不同于用导入的样式表替换所有位置.

I'd do something like the following, which will combine the stylesheet serverside, before it gets to Chrome. The first step is in place because xsl:import is not the same as replacing all places with the imported stylesheets.

  1. 将所有xsl:import替换为xsl:include(导入优先级不适用于xsl:include,因此您可能需要更改代码并改用优先级)
  2. 使用下面的服务器端样式表将它们合并为一个,然后再投放
  3. 等待几个星期(可能是几个月).我已经为Chrome创建了一个修复程序,目前正在与开发人员团队合作,将该修复程序包含到内部版本中.
  1. Replace all xsl:import with xsl:include (import priority isn't applicable to xsl:include, so you may need to change your code and use priorities instead)
  2. Use the server-side stylesheet below to merge them into one before serving
  3. Wait a few weeks (can be months). I've created a fix for Chrome and am currently working with the developers team to include the fix into the build.
<xsl:template match="node()">
    <xsl:copy>
       <xsl:copy-of select="@*"/>
       <xsl:apply-templates select="node()"/>
    </xsl:copy>
</xsl:template>

<xsl:template match="xsl:include">
   <!-- you'll probably want to be a bit more restrictive here -->
   <xsl:copy-of select="document(@href)/xsl:stylesheet/*" />
</xsl:template>

更新:仅需注意:Chrome浏览器错误也出现在Safari中.

Update: Just a note: the Chrome bug appears in Safari too.

这篇关于样式表中的xsl:import和xsl:include在Google Chrome上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 02:44