为什么相对路径不适用于 xsl:include? [英] Why won't relative path work for xsl:include?

查看:30
本文介绍了为什么相对路径不适用于 xsl:include?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个可转换为 PDF 的 XSL 文件.在这个页面的顶部,我有一个很长的CSS样式如

I have a XSL file, which converts to PDF. On the top of this page, I have a very long CSS style such as

<xsl:attribute-set name="Header">
    <xsl:attribute name="font-size">
        <xsl:value-of select="$font-size"/>
    </xsl:attribute>
    <xsl:attribute name="font-weight">bold</xsl:attribute>
    <xsl:attribute name="text-align">center</xsl:attribute>
</xsl:attribute-set>
...

渲染需要很长时间,因此我将它们复制到另一个位置的新页面 (PDF_style.xsl) 中.然后我用

It takes a long time to render so that I copy these into a new page (PDF_style.xsl) in another location. Then I use

<xsl:include href="../allStyles/PDF_style.xsl"/>

但是当我测试它时,系统说它无法归档这个文件位置!

But when I test it, the system says it couldn't file this file location!

注意:allStyles 是我存放每个样式表文件的文件夹,路径是正确的.

Note: allStyles is the folder I store every stylesheet files and the path is a correct one.

是链接外部文件的正确方法吗?还是我必须使用其他东西?

Is <xsl:include href="..." /> a correct way to link an external file? Or do I have to use something else?

推荐答案

xsl:include/@hrefxsl:import/@href 的相对路径是 针对执行包含或导入的 XSLT 文件的目录解析.

A relative path for xsl:include/@href or xsl:import/@href is resolved against the directory of the XSLT file that does the including or importing.

所以,如果您的 XSLT 文件是

So, if your XSLT file is

/xslt/my.xsl

那么 PDF_style.xsl 文件必须在这里:

then the PDF_style.xsl file must be here:

/allStyles/PDF_style.xsl

为了

<xsl:include href="../allStyles/PDF_style.xsl" />

/xslt/my.xsl 中是正确的.

这篇关于为什么相对路径不适用于 xsl:include?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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