It is possible to get a list of all included stylesheets within the xslt process?
I ask because the whole include/import process is done before the execution and I wonder if I have access to this information?
It is possible to get a list of all included stylesheets within the xslt process?
I ask because the whole include/import process is done before the execution and I wonder if I have access to this information?
This short and fully generic transformation produces a hierarchical result (XML tree) that presents all imports/inclusions in any stylesheet tree and avoids infinite loops. Do note that XSLT (both 1.0 and 2.0) allows circular imports.
For example, when we apply this transformation to the following FXSL stylesheet (func-standardXpathFunctions.xsl):
the wanted, correct result is produced:
This stylesheet (Main.xslt)
with its included stylesheets Sub1.xslt and Sub2.xslt
will produce
There may be a different way of doing it; I'm not sure. Also I'm not 100% sure of how the base URI is defined when calling
document('Main.xslt')
, meaning the file name could be resolved relative to the XML instance when you expect it to resolve relative to the XSLT file. In any case, I ran a test with an XML instance residing in a different directory than Main.xslt, and it still worked.Addendum:
For walking the tree recursively, you can do something like this (XSLT1):