Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xml 从xsl模板中选择正确的节点_Xml_Xslt_Xpath - Fatal编程技术网

Xml 从xsl模板中选择正确的节点

Xml 从xsl模板中选择正确的节点,xml,xslt,xpath,Xml,Xslt,Xpath,您好,我正在尝试调用一个名为“按钮”的xsl模板,如果我这样做,我将同时显示“保存”和“删除”按钮。是否有办法只显示“保存”按钮 <xsl:template name="Buttons"> <xsl:param name="list"/> <ButtonList> <xsl:for-each select="$list/*"> <xsl:cho

您好,我正在尝试调用一个名为“按钮”的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> 
Interface.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> 
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

<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> 
<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>
试着改变

<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> 
<xsl:for-each select="$list/*">
致:

<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> 
然后,仅从参数中选择保存项

<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> 
替代解决方案

<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> 
改变

<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> 
<xsl:call-template name="Buttons">
   <xsl:with-param name="list" select="*"/> <--this line needs help!
<xsl:call-template>

<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是什么样子的?@IanRoberts uploaded input XML我需要更改该模板第一部分的行question@bouncingHippo您如何知道需要更改代码中的某一行?编辑了我的answer.oops我忘了更新ButtonList.xsl。你能再看一下吗?@bouncingHippo我没看到任何变化。你先试试我的建议怎么样?你能详细说明一下它怎么不起作用吗?或者,发布完整的XSLT代码和完整的XML示例。
<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>