Merge multiple xslt stylesheets

前端 未结 5 2162
鱼传尺愫
鱼传尺愫 2020-12-06 12:11

I have a xslt stylesheet with multiple xsl:imports and I want to merge them all into the one xslt file.

It is a limitation of the system we are using wh

5条回答
  •  爱一瞬间的悲伤
    2020-12-06 12:39

    It is impossible to include imported stylsheets into the main file without breaking import precedence. For example, you define a top-level variable in an imported stylesheet and redefine it in the main file. If you merge two files into one, you’ll get two variables with the same name and import precedence, which will result in an error.

    The workaround is two replace xsl:import’s with xsl:include’s and resolve any conflicts. After that you are safe to replace xsl:include instructions with the corresponding files’ contents, because that is what XSLT-processor does:

    The inclusion works at the XML tree level. The resource located by the href attribute value is parsed as an XML document, and the children of the xsl:stylesheet element in this document replace the xsl:include element in the including document. The fact that template rules or definitions are included does not affect the way they are processed.

提交回复
热议问题