在 XSLT 导入/包含中使用动态 href? [英] Using dynamic href in XSLT import/include?

查看:31
本文介绍了在 XSLT 导入/包含中使用动态 href?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

The <xsl:import> and <xsl:include> elements seem to behave quite specific. What I am trying to do:

<xsl:import href="{$base}/themes/{/settings/active_theme}/styles.xsl" />

I want to allow loading different themes for my application. I have a settings in my App which stores the "currently active theme" folder name in a xml node. Unfortunately the code above won't work. Does anybody know about a workaround to achieve what I want to do?

edit: just confirmed with a XSLT guru via Twitter... there's no nice way of doing this. Easiest solution in my case will probably be to seperate frontend and backend stylesheets and load them individually to the XSLTProcessor...

解决方案

xsl:import assembles the stylesheet prior to execution. The stylesheet can't modify itself while it is executing, which is what you are trying to achieve.

If you have three variants of a stylesheet for use in different circumstances, represented by three modules A.xsl, B.xsl, and C.xsl, then instead of trying to import one of these into the module common.xsl that contains all the common code, you need to invert the structure: each of A.xsl, B.xsl, and C.xsl should import common.xsl, and you should select A.xsl, B.xsl, or C.xsl as the principal stylesheet module when initiating the transformation.

这篇关于在 XSLT 导入/包含中使用动态 href?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆