|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Boolean true() and false() as strings?
A curious thing (well, to me!)... consider this template rule:
<xsl:template match="sales">
<h2>Regions Selling More than 300 Units:</h2>
<xsl:for-each select="region">
<xsl:variable name="units_gt_300">
<xsl:choose>
<xsl:when test="number(units) > 300">
<xsl:value-of select="true()"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="false()"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:if test="$units_gt_300='true'">
<h3><xsl:value-of select="concat(@name, ' (', units, ' units)')"/></h3>
</xsl:if>
</xsl:for-each>
</xsl:template>Note the assignment of Boolean true() or false() to the variable, and the <xsl:if> test. Why can't the latter be simply: <xsl:if test="$units_gt_300"> i.e., why the need to test vs. the string value "true"? Does using the true() and false() functions in a variable coerce their return values to string type rather than their "native" Boolean? Here's a simple XML doc to run it against: <sales quarter="2001-01">
<region name="Northeast">
<units>374</units>
<amount>12500.26</amount>
</region>
<region name="Southeast">
<units>512</units>
<amount>17692</amount>
</region>
<region name="Southwest">
<units>161</units>
<amount>8349.72</amount>
</region>
<region name="Northwest">
<units>465</units>
<amount>15239.6</amount>
</region>
</sales>(Tested with both Saxon and the Sept. release of IE5.5, btw.) ========================================================== John E. Simpson | "Curiosity killed the cat, http://www.flixml.org | but for a while I was a XML Q&A: http://www.xml.com | suspect." (Steven Wright) XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








