Html 在a<;中选择默认值;选择>;XSL文件中的语句
我有一个项目列表,如下面列出的项目,我试图在默认情况下选择该选项,该选项在“listing”标记中有一个特定标记Html 在a<;中选择默认值;选择>;XSL文件中的语句,html,xslt,html-select,Html,Xslt,Html Select,我有一个项目列表,如下面列出的项目,我试图在默认情况下选择该选项,该选项在“listing”标记中有一个特定标记 _类型 选择聊天室 ... 我是否将xsl:if放错了?很难从您提供的代码中分辨出来,但我猜您希望得到如下结果: <select name="000_type"> <option value="chat" selected="selected"/> <option value="chat"/> </select> <xsl:
_类型
选择聊天室
...
我是否将xsl:if放错了?很难从您提供的代码中分辨出来,但我猜您希望得到如下结果:
<select name="000_type">
<option value="chat" selected="selected"/>
<option value="chat"/>
</select>
<xsl:element name="select">
<xsl:attribute name="name" select="concat(@id,'_type'))"/>
</xsl:element>
<xsl:element name="option">
<xsl:attribute name="value">
<xsl:value-of select="chat"/>
</xsl:attribute>
<xsl:if test="listing/Chat">
<xsl:attribute name="selected">
<xsl:text>selected</xsl:text>
</xsl:attribute>
</xsl:if>
</xsl:element>
在这种情况下,您需要如下所示的XSL:
<select name="000_type">
<option value="chat" selected="selected"/>
<option value="chat"/>
</select>
<xsl:element name="select">
<xsl:attribute name="name" select="concat(@id,'_type'))"/>
</xsl:element>
<xsl:element name="option">
<xsl:attribute name="value">
<xsl:value-of select="chat"/>
</xsl:attribute>
<xsl:if test="listing/Chat">
<xsl:attribute name="selected">
<xsl:text>selected</xsl:text>
</xsl:attribute>
</xsl:if>
</xsl:element>
挑选出来的
很难从您提供的代码中分辨出来,但我猜您希望得到如下结果:
<select name="000_type">
<option value="chat" selected="selected"/>
<option value="chat"/>
</select>
<xsl:element name="select">
<xsl:attribute name="name" select="concat(@id,'_type'))"/>
</xsl:element>
<xsl:element name="option">
<xsl:attribute name="value">
<xsl:value-of select="chat"/>
</xsl:attribute>
<xsl:if test="listing/Chat">
<xsl:attribute name="selected">
<xsl:text>selected</xsl:text>
</xsl:attribute>
</xsl:if>
</xsl:element>
在这种情况下,您需要如下所示的XSL:
<select name="000_type">
<option value="chat" selected="selected"/>
<option value="chat"/>
</select>
<xsl:element name="select">
<xsl:attribute name="name" select="concat(@id,'_type'))"/>
</xsl:element>
<xsl:element name="option">
<xsl:attribute name="value">
<xsl:value-of select="chat"/>
</xsl:attribute>
<xsl:if test="listing/Chat">
<xsl:attribute name="selected">
<xsl:text>selected</xsl:text>
</xsl:attribute>
</xsl:if>
</xsl:element>
挑选出来的
您的代码无效,因为您将一个
标记嵌套在另一个标记中。我相信您需要以下内容之一:
<select name="{@id}_type">
<option value="Chat">
<xsl:if test="listing/Chat">
<xsl:attribute name="selected">selected</xsl:attribute>
</xsl:if>
<xsl:text>Chat</xsl:text>
</option>
</select>
挑选出来的
聊天
或
聊天
前者始终显示“聊天”选项,但仅在满足条件时才选择该选项。除非满足条件,否则后者根本不会显示“Chat”。您的代码无效,因为您将一个
标记嵌套在另一个标记中。我相信您需要以下内容之一:
<select name="{@id}_type">
<option value="Chat">
<xsl:if test="listing/Chat">
<xsl:attribute name="selected">selected</xsl:attribute>
</xsl:if>
<xsl:text>Chat</xsl:text>
</option>
</select>
挑选出来的
聊天
或
聊天
前者始终显示“聊天”选项,但仅在满足条件时才选择该选项。除非满足条件,否则后者根本不会显示“Chat”(聊天)。这很难理解。你能发布你想要的结果吗?这很难理解。你们能发布你们想要的结果吗?谢谢大家!我是根据Ben的密码来实现的。抱歉没有把它清楚地贴在上面。最后的代码如下所示:selectedChat。。。谢谢大家!我是根据Ben的密码来实现的。抱歉没有把它清楚地贴在上面。最后的代码如下所示:selectedChat。。。