您好我正在尝试调用名为&#39; Buttons&#39;的xsl模板。如果我<xsl:with-param name="list" select="*"/>
我将同时显示&#39; save&#39;并且&#39;删除&#39;纽扣。有没有办法只显示&#39; save&#39;按钮?
Interface.xsl
<Cell colspan="1">
<xsl:choose>
<xsl:call-template name="Buttons">
<xsl:with-param name="list" select="*"/> <--this line needs help!
<xsl:call-template>
ButtonList.xsl
<xsl:template name="Buttons">
<xsl:param name="list"/>
<ButtonList>
<xsl:for-each select="$list/*">
<xsl:choose>
<xsl:when test="Action='SAVE'">
//code for style of button
</xsl:when>
<xsl:when test="Action='DELETE'">
//code for style of button
</xsl:when>
</xsl:choose>
</xsl:for-each>
</ButtonList>
<xsl:template>
输入xml
<StaticLabelList>
<StaticLabel style="font-family:Arial;color:#1370df;font-size:10pt">
<Name><![CDATA[SECTION_TITLE]]></Name>
<Caption><![CDATA[Buttons]]></Caption>
</StaticLabel>
</StaticLabelList>
<ButtonList>
<Button style="font-family:Arial Narrow;color:#E6E7E8;font-size:10pt;background-color:#94c1f6;text-decoration:none">
<Label><![CDATA[SAVE]]></Label>
<Url><![CDATA[#]]></Url>
<Onclick><![CDATA[submitForm('/Controller/SEND','theForm'); return (false);]]></Onclick>
<Action><![CDATA[SAVE]]></Action>
<ReadOnly rtexprvalue="true"><![CDATA[mb.isReadonlyButton("N",2,2)]]></ReadOnly>
</Button>
<Button style="font-family:Arial Narrow;color:#E6E7E8;font-size:10pt;background-color:#94c1f6;text-decoration:none">
<Label><![CDATA[DELETE]]></Label>
<Url><![CDATA[#]]></Url>
<Onclick><![CDATA[submitForm('/Controller/DELETE','theForm'); return (false);]]></Onclick>
<Action><![CDATA[PREV]]></Action>
<ReadOnly rtexprvalue="true"><![CDATA[mb.isReadonlyButton("Y",2,2)]]></ReadOnly>
</Button>
答案 0 :(得分:0)
尝试更改
<xsl:for-each select="$list/*">
为:
<xsl:for-each select="$list/*[Action = 'SAVE']">
然后,只从参数中选择SAVE项目。
替代解决方案
更改
<xsl:call-template name="Buttons">
<xsl:with-param name="list" select="*"/> <--this line needs help!
<xsl:call-template>
要
<xsl:call-template name="Buttons">
<xsl:with-param name="list" select="*[Action = 'SAVE']"/> <--this line needs help!
<xsl:call-template>
然后,只有SAVE项目最终会被传递给被调用的模板。