not

Negates a boolean value

Description

The fn:not function accepts a sequence of items, from which it calculates the effective boolean value of the sequence as a whole before negating it. This means that when $arg is either a single boolean value false, a zero-length string, the number 0 or NaN, or the empty sequence, it returns true. Otherwise, it returns false.

Parameters

Description

arg:boolean()

the sequence whose effective boolean value is negated

Examples

XPath

Results

Explanation

not(32 > 20)

false

32 > 20 is true.

not(parse-xml('<catalog><product/><product/></catalog>')//product)

false

there is at least one product element in catalog.xml

not(true())

false

The opposite of true.

not(())

true

The effective boolean value of the empty sequence is false.

not('')

true

The effective boolean value of a zero-length string is false.

not(0)

true

The effective boolean value of the number 0 is false.

In a generator

Copy the snippet below and paste it in Freemapper, under a language node inside the generators element. Each line of the pattern prints the result of one example; to see them, run mi generate <project> <language> example-not.

[e] example-not
    [e] start
        [e] match
            [v] /
        [e] body
            [e] write-pattern
                [v] examples
    [e] patterns
        [e] examples
            [v] E01: {{ not(32 > 20) }}
            [v] E02: {{ not(parse-xml('<catalog><product/><product/></catalog>')//product) }}
            [v] E03: {{ not(true()) }}
            [v] E04: {{ not(()) }}
            [v] E05: {{ not('') }}
            [v] E06: {{ not(0) }}

See Also