Html XSLT中的条件嵌套元素
我有一个XSLT模板,它有条件地需要嵌套在Html XSLT中的条件嵌套元素,html,xslt,dry,Html,Xslt,Dry,我有一个XSLT模板,它有条件地需要嵌套在anchor元素中 例如: <xsl:choose> <xsl:when test="$foo = 1"> <a href="/bar"> <xsl:call-template name="Baz"> <xsl:with-param name="ParamA" select="$A" /> <xsl:with-param
anchor
元素中
例如:
<xsl:choose>
<xsl:when test="$foo = 1">
<a href="/bar">
<xsl:call-template name="Baz">
<xsl:with-param name="ParamA" select="$A" />
<xsl:with-param name="ParamB" select="$B" />
<xsl:with-param name="ParamC" select="$C" />
<xsl:with-param name="ParamD" select="$D" />
<xsl:with-param name="ParamE" select="$E" />
<xsl:with-param name="ParamF" select="$F" />
</xsl:call-template>
</a>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="Baz">
<xsl:with-param name="ParamA" select="$A" />
<xsl:with-param name="ParamB" select="$B" />
<xsl:with-param name="ParamC" select="$C" />
<xsl:with-param name="ParamD" select="$D" />
<xsl:with-param name="ParamE" select="$E" />
<xsl:with-param name="ParamF" select="$F" />
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
如您所见,调用模板
和传递的参数周围存在大量重复的代码
是否有一种更整洁、有条件地嵌套元素的方法?您可以在变量中调用模板,并将变量的结果放在choose中