Name
not()
Returns the negation of its argument. If the
argument is not a boolean value already, it is converted to a
boolean value using the rules described in the boolean()
function entry.
Syntax
[1.0] booleannot(
boolean
)
[2.0] xs:booleannot(
item()*
)
Inputs
A boolean value, or more commonly, an XPath expression that evaluates to a boolean value.
Output
false
if the input
parameter is true
; true
if the input parameter is false
.
Defined in
[1.0] XPath section 4.3, “Boolean Functions.”
[2.0] XQuery 1.0 and XPath 2.0 Functions and Operators section 9.3, “Functions on Boolean Values.”
Example
To demonstrate the not()
function, we’ll use the same
stylesheet and XML document we used for the boolean()
function. Here’s our XML
document:
<?xml version="1.0" encoding="utf-8"?>
<!-- chocolate.xml -->
<report month="8" year="2006">
<title>Chocolate bar sales</title>
<brand>
<name>Lindt</name>
<units>27408</units>
</brand>
<brand>
<name>Callebaut</name>
<units>8203</units>
</brand>
<brand>
<name>Valrhona</name>
<units>22101</units>
</brand>
<brand>
<name>Perugina</name>
<units>14336</units>
</brand>
<brand>
<name>Ghirardelli</name>
<units>19268</units>
</brand>
</report>
We’ll process this document with the following stylesheet,
which uses not()
instead of
boolean()
. The boolean()
function converts its
argument to a boolean value; the not()
function implicitly uses
boolean()
to convert its
argument to a boolean value, and then negates it.
<?xml version="1.0"?>
<!-- not.xsl --> <xsl:stylesheet version="1.0" ...
Get XSLT, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.