我有一个相对复杂的xsl:apply-templates调用:
<xsl:apply-templates select="columnval[@id
and not(@id='_Name_')
and not(@id='Group')
and not(@id='_Count_')]"/>
表达式在其他地方被重复使用,例如:
<xsl:apply-templates select="someothernode[@id
and not(@id='_Name_')
and not(@id='Group')
and not(@id='_Count_')]"/>
我希望能够将其归纳为一般性内容,这样我就可以在其他地方定义并重复使用。然而,这似乎行不通:
<xsl:variable name="x">@id and not(@id='_Name_') and not(@id='Group') and not(@id='_Count_')</xsl:variable>
<xsl:apply-templates select="columnval[$x]"/>
<xsl:apply-templates select="someothernode[$x]"/>
有没有更好/不同的方法来做这件事?我只想在多个不同的xsl:apply-templates调用中重复使用xpath表达式(其中一些从不同的子元素选择)。
这将在客户端应用程序中使用,所以很遗憾我不能使用任何扩展或切换到XSLT 2。 :(
谢谢。