XSLT Attribute not being added
Posted
by shaunhare.co.uk
on Stack Overflow
See other posts from Stack Overflow
or by shaunhare.co.uk
Published on 2010-03-29T08:23:59Z
Indexed on
2010/03/29
8:43 UTC
Read the original article
Hit count: 439
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>
© Stack Overflow or respective owner