I have an object with data annotations for serialization. It has a boolean property which is true (tested with debugger) so 100% certain, but when I have this in the xslt:
<xsl:for-each select="order/Coupons/orderedCoupons" >
<tr>
<td>Discount <xsl:value-of select="@code"/></td>
<td>
<xsl:choose>
<xsl:when test="@isperc='true'">
<xsl:value-of select="@disvalue"/>%
</xsl:when>
<xsl:otherwise>Epic fail
€ <xsl:value-of select="format-number(@disvalue, '#.###,00', 'euro')" />
</xsl:otherwise>
</xsl:choose>
</td>
</tr>
</xsl:for-each>
It always displays epic fail, so the test always fails. I also have tried:
- @isperc=’true’
- @isperc=1
- boolean(@isperc)
- @isperc = true()
some more background info: it is an asp.net object which I serialize with build in data annotations. The XSLT support in .Net is 1.0 only.
edit piece of my coupon.cs
[XmlAttribute("isperc")]
public bool IsPerc
{
get { return _isPerc; }
}
it is not nullable, but as the 2nd commentor pointed out, what is the value of <xsl:value-of select="@isperc"/> well, it seems empty. it parses as nothing in the html. Not a whitespace, not null etc. that is strange because the boolean is true…
edit2 this also outputs nothing <xsl:value-of select="string(@isperc)"/>, so this also fails <xsl:when test="string(@isperc) = 'true'">
should match a C# boolean type.
A workaround I’ve seen is to convert the boolean value to a number, though;