ameliabob Posted October 9, 2008 Share Posted October 9, 2008 I am trying to put checkboxes in a table and to have them checked or not depending on a field in the XML fileThe code that I am using is: <xsl:if test="used == 'true'" > <input type="checkbox" checked=true name="able" value="yes" /> <otherwise> <input type="checkbox" name="able" value="yes" /> </otherwise> </xsl:if> The field that I am testing is "used" and its value will either be "true" or "false" (the words). As you may imagine I am getting nasty diagnostics coming back. Link to comment Share on other sites More sharing options...
aalbetski Posted October 10, 2008 Share Posted October 10, 2008 <input type="checkbox" checked="true" name="able" value="yes" />All attributes must be in quotes Link to comment Share on other sites More sharing options...
ameliabob Posted October 10, 2008 Author Share Posted October 10, 2008 <input type="checkbox" checked="true" name="able" value="yes" />All attributes must be in quotesThat fixed that one quickly. Now it says xsl:if : could not compile test expression 'used == 'true'' Link to comment Share on other sites More sharing options...
aalbetski Posted October 10, 2008 Share Posted October 10, 2008 this is a case of being multi-lingual. '==' is javascript, not xslt, just use '=' Link to comment Share on other sites More sharing options...
boen_robot Posted October 11, 2008 Share Posted October 11, 2008 Also note that you're using <otherwise>, when you should be using <xsl:otherwise> and in a choose instead, like so: <xsl:choose> <xsl:when test="used = 'true'"> <input type="checkbox" checked="true" name="able" value="yes" /> </xsl:when> <xsl:otherwise> <input type="checkbox" name="able" value="yes" /> </xsl:otherwise> </xsl:choose> In addition, I notice that the only difference in your case in the checked attribute. Because of that, I'd suggest you use xsl:attribute conditionally instead: <input type="checkbox" name="able" value="yes"> <xsl:if test="used = 'true'"> <xsl:attribute name="checked">checked</xsl:attribute> </xsl:if> </input> Link to comment Share on other sites More sharing options...
ameliabob Posted October 31, 2008 Author Share Posted October 31, 2008 Also note that you're using <otherwise>, when you should be using <xsl:otherwise> and in a choose instead, like so: <xsl:choose> <xsl:when test="used = 'true'"> <input type="checkbox" checked="true" name="able" value="yes" /> </xsl:when> <xsl:otherwise> <input type="checkbox" name="able" value="yes" /> </xsl:otherwise> </xsl:choose> In addition, I notice that the only difference in your case in the checked attribute. Because of that, I'd suggest you use xsl:attribute conditionally instead: <input type="checkbox" name="able" value="yes"> <xsl:if test="used = 'true'"> <xsl:attribute name="checked">checked</xsl:attribute> </xsl:if> </input> Would the attribute transfer as showing the checkmark in the checkbox? Link to comment Share on other sites More sharing options...
boen_robot Posted November 9, 2008 Share Posted November 9, 2008 Would the attribute transfer as showing the checkmark in the checkbox?Um... yes?What XSLT in general does is to generate another XML or (X)HMTL code and that code is then parsed. Try to do the same in a plain XHTML document, and if it happens there, it will happen when in XSLT as well.As far as I know, <input type="checkbox" name="able" value="yes" checked="checked" /> is indeed a valid XHTML that shows a checked checkbox. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.