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
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
no...
but you could maybe workaround the problem by using relative URLs and/or passing parameters into the stylesheet.
In most XSLT processor, you can add custom functions as extensions. For example here is Saxon's documentation how to do that.
No need for any extension functions or even parameters to do that!
Any relative URLs used in the
href
attribute of an<xsl:import>
or<xsl:include>
instruction are resolved based on the URL of the current XSLT stylesheet -- it only needs to have an URL, which is vlearly stated as true in the question above. This is very convenient in importing/including XSLT stylesheets.The
document()
function also will resolve a relative URL in a similar way, thus making any additional XML document accessible using anrelative URL.Lastly, here is an example how this facilities are massively used in a big library of XSLT functions and templates (FXSL 2.x):
This may work for your setup:
For example,
Not AFAIK (though you could always pass it as a param to the transform), but I'm not clear why relative paths won't work for you here.
You can send it into the style-sheet from outside using xsl:param. Then you need to determine what the current path is when invoking the from the outside ;)