12
A
回答
6
您可以使用xsl:param从外部将它发送到样式表中。然后你需要确定从外部调用当前的路径是什么;)
3
没有...
但你也许可以解决方法通过使用相对URL和/或参数传递到样式表的问题。
1
不AFAIK(虽然你总是可以将它作为参数传递给变换),但我不清楚为什么相对路径赢得'在这里为你工作。
4
在Windows上MSXSL,您可以使用脚本扩展这样的:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:user="http://tempuri.org/msxsl"
>
<msxsl:script language="JScript" implements-prefix="user">
<![CDATA[
var fso = new ActiveXObject("Scripting.FileSystemObject");
function getCurrentPath(){
return fso.GetFolder(".").Path
}
]]>
</msxsl:script>
<xsl:template match="/">
<xsl:value-of select="user:getCurrentPath()"/>
</xsl:template>
</xsl:stylesheet>
其他XSL处理器支持类似的方法来使用外部资源(脚本语言,函数库等),所以这只是一个例。
2
在大多数XSLT处理器中,您可以添加自定义函数作为扩展。例如这里是Saxon's documentation该怎么做。
4
有没有办法从xslt文件中获取当前 文件夹路径?
需要它来寻找其他XML和XSLT 文件
无需任何扩展功能,甚至参数来做到这一点!
在<xsl:import>
或<xsl:include>
指令的href
属性使用任何相对 URL被基于当前XSLT样式表的URL解析 - 它仅需要具有一个URL,它是vlearly表述为在上面的问题中是真的。这在导入/包括XSLT样式表时非常方便。
的document()
功能也会以类似的方式解决相对URL,因此利用anrelative URL进行任何额外的XML文档进行访问。
最后,这里是an example如何设施,在一个大库的XSLT的功能和模板(FXSL 2.x)大量使用:
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:f="http://fxsl.sf.net/"
exclude-result-prefixes="xs xdt f"
>
<!--
This module contains the FXSL versions of the "standard" XPath functions
These are intended as convenience functions, so that they can be passed
as parameters to other functions (e.g. to f:zipWith())
or curried and passed as parameters (e.g. to f:map())
-->
<xsl:import href="func-curry.xsl"/>
<xsl:import href="func-compose-flist.xsl"/>
<xsl:import href="func-standardArithmeticXpathFunctions.xsl"/>
<xsl:import href="func-standardBooleanXpathFunctions.xsl"/>
<xsl:import href="func-standardStringXpathFunctions.xsl"/>
<xsl:import href="func-standardNodesXpathFunctions.xsl"/>
<xsl:import href="func-standardSequencesXpathFunctions.xsl"/>
<xsl:import href="func-standardAggregateXpathFunctions.xsl"/>
<xsl:import href="func-standardDateTimeXpathFunctions.xsl"/>
<xsl:import href="func-standardXSLTXpathFunctions.xsl"/>
<xsl:import href="func-standardAxisXpathFunctions.xsl"/>
</xsl:stylesheet>
4
这可能是你的设置工作:
<xsl:value-of select="system-property('user.dir')"/>
例如,
<xsl:value-of select="document(concat(system-property('user.dir'),'/',filename,'.xml'))//title[1]"/>
相关问题
- 1. 获取当前文件夹路径
- 2. 获取当前登录用户的文档文件夹路径
- 3. 如何从给定文件夹路径获取文件夹路径?
- 4. 从路径获取文件夹名称
- 5. asp.net获取路径页文件夹URL
- 6. 获取Vista文件夹路径
- 7. delphi获取文件夹路径
- 8. 获取文件夹图标路径
- 9. 仅当Linux文件夹中存在子文件夹时才获取当前目录(非完整路径)
- 10. 获取当前文件夹名称
- 11. 获取的当前项目文件夹
- 12. 将文件粘贴到文件夹时获取文件夹的路径
- 13. iPhone:获取资源文件夹子文件夹内的文件路径
- 14. Python:获取文件夹中找到的文件的路径
- 15. 如何在js文件中获取文件夹“node_modules”的路径?
- 16. 如何获取jar文件中的文件夹路径?
- 17. 从完整文件路径获取文件夹名称
- 18. 从Active Directory获取配置文件路径和主文件夹
- 19. VBS - 获取程序文件的文件夹路径?
- 20. VBA Excel获取文件路径(以文件夹结尾)
- 21. Xamarin:获取资产文件夹中文件的绝对路径
- 22. 如何从文件路径获取父文件夹的名称?
- 23. 在Windows上的正则表达式,获取当前文件夹的文件夹路径
- 24. 如何获取我的项目中文件夹的路径(以及该文件夹中文件的路径)?
- 25. 获取文件路径的文件名
- 26. 从文件路径获取文件名
- 27. 获取文件的路径
- 28. asp:FileUpload获取文件路径
- 29. html5获取文件路径
- 30. Symfony获取文件路径
不知道为什么这是被投票。它实际上工作。 – Tomalak 2009-02-13 14:59:58
对不起。我投票选择使用非标准扩展名,但在添加我的答案后,我意识到我提出了同样的问题。我认为没有“标准”的方式来做到这一点。 (除了使用参数) – 2009-02-13 15:05:00