XSLT Attribute not being added
- by shaunhare.co.uk
Trying to mark radio inputs as selected with XSLT 1.0 using the below xslt code but this does not produced the desired result
desrired result
<input type="radio" value="available" title="email" selected="selected" />
Actual output
<input type="radio" value="available" title="email" selected />
Anyone any ideas why not please?
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>