My 2 pence worth on a simple ( but effective ) alternative ( only psuedocode provided for illustration. proceed with caution :)
Outline of the approach:
An alternative solution can consist of a simple wrapper script ( eg shell , bash script or other) to invoke your main xsl, use of name xslt modes, the main xslt file, a simple (blank) statically specified xslt file .
In the main xsl, include a static xsl file , that will call/load all the dynamically included xslt. The main xsl will then operate in 2 modes: the normal mode(unspecified mode), where it will load extension xsl files included in itself , and in the static xls, and process any input files, or do what ever good stuff its intended to do. The second mode, preprocessor mode , will be intended for loading the dyanimically specified xsl instances/files. This mode will be invoked as a preprocessor stage for the main processing run. The process flow for the main xslt would be to call it with the preprocessor mode specified, and then to call it again with the normal processing mode indicated.
Implementation hints :
For each xlator define a n extension xslt file, ext_xsl_container , whose purpose is to include any extension xslt.
eg
<xsl:stylesheet >
<!-- main xslt -->
<xsl:import href="../xsl/ext_xsl_container.xsl/>
<!--param: list of dynamically specified extension xsl -->
<xsl:param name="extXslUrlList"/>
<!--param:preprocessor mode flag, with default set to false -->
<xsl:param name="preProcModeLoadXslF" select="false()" type="xs:boolean"
<!-- param: path to the staticall included ext_xsl_container: with default value set -->
<xsl:param name="extXslContainerUrl" select="'../xsl/ext_xsl_container.xsl'"/>
<xsl:if test=" ($preProcModeLoadXslF=true())" >
<xsl:call-template name="loadDynamicXsl" mode="preprocess_load_xsl"
</xsl:if>
....
</xsl:stylesheet>
The ext_xslt_container style sheet will include any extension xslts. It can be dynamically updated at run time by editing it ( as an xml document ) , adding include statement for extension xsl stylesheets.
eg
<!-- ext xsl container : ext_xsl_container.xsl-->
<xsl:stylesheet
<xsl:include href="ext_xsl_container.xsl"/>
....
</xsl:stylesheet
Create a small template , say template_load_ext_xsl, with an assigned mode , say mode="preprocess_load_xsl"
eg
<xsl:template name="loadDynamicXsl" mode="preprocess_load_xsl">
<!-- param: path to the staticall included ext_xsl_container-->
<xsl:param name="extXslContainerUrl"/>
<!--param: list of dynamically specified extension xsl -->
<xsl:param name="extXslUrlList"/>
<!-- step 1, [optional ] open the ext Xsl container file -->
<!-- step 2 [optional] clear contexts of the ext X -- >
<!-- step3 compile a list of include elements, one per each ext Xsl file -->
<!-- step 4 [optional] create a union of the include elements created with the content of the xsl container file : ie append content >
<!-- step 5 : write the union list of incudes to the ext XSL container file -->
<!-- DONE --->
</xsl:template>
The template will take as arguments, the name of the ex_xsl_container, and a list of extension xsl files ( including their paths)
it will then open the ext_xsl_container file as an xml document , add ( options to append, or clear file and add new code ) statements for each extension : xsl, save the file and exit
Next when you run the main xsl in normal execution mode , it willl include the template loadDynamicXsl, which will inturn include the extension xslt files specifed at run time
Create a simple wrapper script ( eg bash , or shell script) that will take in arguments to the main xslt, and a option to run the preprocessor mode. The script will simply call the main xslt twice , if the option for the preprocessor mode is enabled , and enabling the preprocessor mode in the first run , followed by a 2nd call in normal mode