尝试使用以下 xslt 代码将无线电输入标记为使用 XSLT 1.0 选择,但这不会产生所需的结果
期望的结果
<input type="radio" value="available" title="email" selected="selected" />
实际输出
<input type="radio" value="available" title="email" selected />
任何人有什么想法为什么不请?
XSLT
<xsl:variable name="selected">selected</xsl:variable>
<xsl:for-each select="item">
<tr>
<td><xsl:value-of select="title" /></td>
<td>
<input type="radio" value="available" >
<xsl:attribute name="name">
<xsl:value-of select="title" />
</xsl:attribute>
<xsl:if test="category='available'">
<xsl:attribute name="selected">
<xsl:value-of select="$selected"/>
</xsl:attribute>
</xsl:if>
</input>
</td>
<td>
<input type="radio" value="unavailable" >
<xsl:attribute name="name">
<xsl:value-of select="title" />
</xsl:attribute>
<xsl:if test="category='unavailable'">
<xsl:attribute name="selected">
<xsl:value-of select="$selected"/>
</xsl:attribute>
</xsl:if>
</input>
</td>
<td>
<input type="radio" value="warning" >
<xsl:if test="category='warning'">
<xsl:attribute name="selected">
<xsl:value-of select="$selected"/>
</xsl:attribute>
<xsl:attribute name="name">
<xsl:value-of select="title" />
</xsl:attribute>
</xsl:if>
</input>
</td>
</tr>
</xsl:for-each>