My 2 pence is worth a simple (but effective) alternative (psuedocode only for illustration). Be careful:)
Brief description of the approach: An alternative solution may consist of a simple shell script (for example, a shell, bash script or another) to call the main xsl, use the names of xslt modes, the main xslt file, a simple (empty) statically defined xslt file.
In the main xsl, include a static xsl file that will call / load all dynamically included xslt. Then the main xsl will work in two modes: in normal mode (unspecified mode), where it will load the xsl extension files included in itself and in static xls, and process any input files, or do what has ever been useful for doing it. The second mode, preprocessor mode, will be designed to load dyanimically specified xsl / file instances. This mode will be called as a preprocessor stage for the main processing run. The process thread for the main xslt would consist of calling it with the specified preprocessor mode, and then calling it again with the specified normal operating mode.
Implementation recommendations: For each xlator, define the xslt n ext_xsl_container extension file, the purpose of which is to include any xslt extension. 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 stylesheet will contain any xslts extension. It can be dynamically updated at run time by editing it (as an XML document) by adding an include statement for xsl extension 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 the mode assigned, say mode = "preprocess_load_xsl" for example
<xsl:template name="loadDynamicXsl" mode="preprocess_load_xsl"> <xsl:param name="extXslContainerUrl"/> <xsl:param name="extXslUrlList"/> </xsl:template>
The template will take as arguments the name ex_xsl_container and the list of xsl extension files (including their paths) it will open the ext_xsl_container file as an XML document, add (options for adding or cleaning the file and adding new code) for each extension: xsl, save the file and will come out
Next, when you start the main xsl in normal runtime, it will include the loadDynamicXsl template, which will include the xslt extension files specified at runtime
Create a simple shell script (for example, bash or shell script)), which will take the arguments for the main xslt and the ability to run the preprocessor. The script will simply call the main xslt twice if the option for preprocessor mode is turned on and turns on preprocessor mode on first run, and then a second call in normal mode