xslt get the file current folder path

2019-02-06 04:29发布

Is there a way to get the current folder path from within a xslt file?

Need it to locate other xml and xslt files. We have different customer folders and will need to successfully find the correct files.

Cheers

标签: xslt
7条回答
虎瘦雄心在
2楼-- · 2019-02-06 05:17

In MSXSL on Windows, you can use a script extension like this:

<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>

Other XSL processors support similar methods to use external resources (scripting languages, function libraries etc.), so this is just an example.

查看更多
登录 后发表回答