我2个便士一个简单的(但有效)替代(仅设置伪码用于说明进行谨慎:)该方法的
概要。 的备选解决方案可以由一个简单的包装脚本(例如shell,bash脚本或其他)来调用您的主要xsl,使用名称xslt模式,主要xslt文件,一个简单的(空白)静态指定的xslt文件。
在主要的xsl中,包含一个静态xsl文件,它将调用/加载所有动态包含的xslt。然后,主要的xsl将以2种模式运行:普通模式(未指定模式),它将在其中加载扩展xsl文件以及静态xls文件,并处理任何输入文件,或者执行任何有用的内容做。第二种模式,预处理器模式,将用于加载指定的xsl实例/文件。该模式将作为主处理运行的预处理阶段调用。主xslt的处理流程是使用指定的预处理器模式调用它,然后用指定的正常处理模式再次调用它。
实现提示: 对于每个xlator,定义一个n扩展xslt文件ext_xsl_container,其目的是包含任何扩展名xslt。 例如
<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>
的ext_xslt_container样式表将包括任何扩展XSLT文件。它可以在运行时通过编辑(作为xml文档)动态更新,为扩展xsl样式表添加include语句。 如
<!-- ext xsl container : ext_xsl_container.xsl-->
<xsl:stylesheet
<xsl:include href="ext_xsl_container.xsl"/>
....
</xsl:stylesheet
创建一个小的模板,说template_load_ext_xsl,具有分配的模式,说模式= “preprocess_load_xsl” 如
<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>
模板将作为参数,ex_xsl_container的名字,和扩展XSL文件(包括路径)的列表 它就会打开ext_xsl_container文件作为一个XML文档,添加(选择追加,或明确的文件,并添加新的代码)每个扩展语句:XSL,保存文件和退出
下,当你运行在正常执行模式的主要XSL,它预订购包括模板loadDynamicXsl,这将inturn包括在运行时specifed扩展XSLT文件
创建一个简单的包装脚本(如bash中,或shell脚本),它将取得主xslt的参数,并运行预处理器模式。该脚本会简单地调用主XSLT两次,如果用于预处理模式的选项已启用,使在第一次运行的预处理模式,其次是在正常模式下的第二个呼叫
使用 –
bvb1909