Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

xsl boolean() function and True/False

Status
Not open for further replies.

sonnysavage

Programmer
May 29, 2002
130
US
I'm parsing some xml using xsl. I have some xml elements which are given the values of True and False. I want to use those values for a boolean test, but the boolean() function returns true for both of them (it tests whether string length is greater than zero).

Does anyone know of a quick way to convert True and False text strings to one or zero?
 
Make sure you use the new xsl namespace.
<xsl:stylesheet version=&quot;1.0&quot; xmlns:xsl=&quot;
<xsl:value-of select=&quot;boolean('hello')&quot;/>
- this should evaluate to true
<xsl:value-of select=&quot;boolean('')&quot;/>
- this should evaluate to false

The <xsl:stylesheet xmlns:xsl=&quot; working draft is completely different and things like boolean might not work properly.

If you want to get a job done, ask a busy person. (Sherry Conway Appel - American writer)
 
But that's exactly my problem, the boolean() function evaluates length for strings. The functionality that I was looking for was this:
Code:
boolean(&quot;false&quot;) = FALSE
boolean(&quot;true&quot;) = TRUE

Both cases, however, evaluate to true. I ended up storing 1 for true and 0 for false in the XML, and I evaluated it this way:
Code:
boolean(number(&quot;1&quot;)) = TRUE
boolean(number(&quot;0&quot;)) = FALSE
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top