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

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

问题描述

< xsl:import> < xsl:include> 元素似乎表现得非常具体。
我要做的是:

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" />

我想允许为我的应用程序加载不同的主题。我的应用程序中有一个设置,它在xml节点中存储当前活动主题文件夹名称。
不幸的是,上面的代码不起作用。
有没有人知道一个解决方法来实现我想做的事情?

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?

编辑:
刚刚通过Twitter确认了XSLT大师......这样做没有好办法。在我的情况下最简单的解决方案可能是分离前端和后端样式表并将它们单独加载到XSLTProcessor ......

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在执行之前组装样式表。样式表在执行时无法自行修改,这正是您要实现的目标。

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.

如果您有三种样式表变体可供在不同情况下使用,由三个模块A.xsl,B.xsl和C.xsl表示,然后不是尝试将其中一个导入到包含所有公共代码的模块common.xsl中,而是需要反转结构:A中的每一个。 xsl,B.xsl和C.xsl应该导入common.xsl,并且在启动转换时应该选择A.xsl,B.xsl或C.xsl作为主要样式表模块。

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 import / include中使用动态href?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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