Wednesday, February 18, 2026

XSLT Boolean Functions | not function

 functions are categorized as Boolean, string, number, and node-set.

You can also pass expressions as parameters to the functions.

All the XPath core functions are defined within the default namespace. 

As a result, you need not prefix the function name with the namespace name.

If you use end-user defined functions or any third party functions, you need to specify the name of the namespace as the prefix to the function name.

Using Boolean Functions

You can use Boolean functions, boolean boolean(object) to return the Boolean values, true or false. Two Boolean functions available in XSLT are:

  • boolean false(): Returns the value false to the resultant document. You can use this function in conditional elements, such as <xsl:if > and <xsl: when>, where a constant boolean value is required.

  • boolean true(): Returns the value true to the result document. Similar to the false() function, you can use this function with the conditional elements.

The boolean() Function

The boolean() function converts the value that it receives to Boolean datatype. The argument passed to the boolean() function can be of any datatype. Depending on the datatype of the argument passed, this function returns a true or false value.

Datatype of Argument Passed

Boolean Value Returned

Numeric Value

True

Numeric Value Zero

False

Node Set

True

Empty Node Set

False

Boolean Value

Boolean value true or false, whichever was passed

String

False if the string does not contain any characters and true if it does

The syntax for the boolean() function is:

boolean(value)

The not() Function

The not() function returns a Boolean value depending on the input value. If the input value is true, the not() function returns false and if the value is false, it returns true. The syntax for the not() function is:

not(condition) Ex:<xsl:for-each select="//Software"><xsl:choose><xsl:when test="not(Key=4578)"><xsl:value-of select="Name"/><xsl:value-of select="Key"/></xsl:when><xsl:when test="Key='3DT'"><xsl:value-of select="Name"/><xsl:value-of select="Key"/></xsl:when></xsl:choose>     
 the not(Key=4578) function prompts the XML file to display information pertaining to all entries except the value 4578.


No comments:

Post a Comment

SOA Overview Part-1

  Middleware It provides a mechanism for the process to interact with other processes running on multiple network machines. Advantages...