XSLT for Dummies
|
Chapter 11 - XPath Data Types and Functions | |
XSLT For Dummies | |
by Richard Wagner | |
Hungry Minds 2002 |
The final major data type XSLT deals with is boolean, which is a simple binary state (true or false). The four built-in functions for boolean values are: not() , true() , false() , and boolean() .
Returning the opposite value
To return a value thats opposite from the one you have, you can use the not() function: boolean not(boolean) The following xsl:if instruction evaluates to true if the myvar variable is not true: <xsl:if test="not($myvar)"> This was not true. </xsl:if>
Returning true and false values
To return a true value (no, not the hardware store), use the true() function: boolean true() To return a false value, use the false() function: boolean false()
Converting to a boolean
You can convert a value to a boolean with the boolean() function. A string and node returns true when it is not empty, whereas a number is true if it is not equal to . The syntax is: boolean boolean(object)
|