首页 > 解决方案 > 将下拉菜单的默认值设置为否

问题描述

我有一个 xslt 代码,我们从 xml 文件中获取下拉值。现在我想将下拉值默认为 NO。

下面是代码:

<td colspan="2" align="left">product:


                    <xsl:apply-templates select="//infor/item/" mode="dropDown">
                      <xsl:with-param name="xmlListFile">
                        <xsl:value-of select="$"/>xyz.xml
                      </xsl:with-param>
                    </xsl:apply-templates>

标签: xslt-2.0

解决方案


根据您提供的内容,默认值可以设置为“否”,如下所示:尽管@Martin Honnen 所说的需要了解您的具体实现和内容

   <xsl:variable name="dropDown_Value">
        <xsl:apply-templates select="//infor/item/" mode="dropDown">
            <xsl:with-param name="xmlListFile">
                <xsl:value-of select="$" />xyz.xml
            </xsl:with-param>
        </xsl:apply-templates>
    </xsl:variable>
   <xsl:choose>
        <xsl:when test="$dropDown_Value != ''">
            <xsl:value-of select="$dropDown_Value" />
        </xsl:when>
        <xsl:otherwise>
            <xsl:value-of select="'NO'" />
        </xsl:otherwise>
    </xsl:choose>

但是,有必要了解您的要求的详细信息。请相应地编辑您的问题。不要将代码放在注释中。


推荐阅读