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. C#如何獲取當前文件夾路徑的所有子文件夾
- 6. 獲取文件的路徑 - XSLT
- 7. 從當前目錄獲取子文件夾中文件的相對路徑
- 8. 如何獲取當前打開的文件夾的文件路徑?
- 9. 獲取當前文件名時,只有文件夾路徑被稱爲
- 10. HTML - 獲取當前html文件保存在文件夾中的路徑
- 11. 獲取路徑的路徑,當前類文件
- 12. 獲取當前項目中文件的文件路徑
- 13. 如何從給定文件夾路徑獲取文件夾路徑?
- 14. 從路徑獲取文件夾名稱
- 15. 獲取特定文件夾路徑
- 16. 在jsp中獲取文件夾路徑
- 17. 獲取WordPress安裝文件夾路徑
- 18. delphi獲取文件夾路徑
- 19. asp.net獲取路徑頁文件夾URL
- 20. 獲取Vista文件夾路徑
- 21. 獲取文件夾圖標路徑
- 22. 獲取chrome文件夾路徑c#
- 23. 從文件夾路徑獲取Outlook中的MAPI文件夾
- 24. 僅當Linux文件夾中存在子文件夾時才獲取當前目錄(非完整路徑)
- 25. Python - 從文件路徑中提取文件夾路徑
- 26. 獲取當前文件夾名稱
- 27. 獲取的當前項目文件夾
- 28. 文件夾路徑
- 29. 將文件粘貼到文件夾時獲取文件夾的路徑
- 30. iPhone:獲取資源文件夾子文件夾內的文件路徑
不知道爲什麼這是被投票。它實際上工作。 – Tomalak 2009-02-13 14:59:58
對不起。我投票選擇使用非標準擴展名,但在添加我的答案後,我意識到我提出了同樣的問題。我認爲沒有「標準」的方式來做到這一點。 (除了使用參數) – 2009-02-13 15:05:00