# Xpath10 boolean

`xpath10-boolean` · version 1.0.0 · Structured formats · free, no key needed

Evaluate an XPath 1.0 boolean expression: comparisons, and, or, not, starts-with, contains, and boolean conversion.

**Use when you need to: xpath 1.0 boolean result · xpath and or not true and false · xpath equality and relational comparison.**

## Decide before calling

Read the [versioned contract](/v1/tools/xpath10-boolean/versions/1.0.0) and the supported scope below. Reuse `xpath10-boolean@1.0.0` when your input, required output and limits match it. Choose another approach for an unsupported operation.

## Explain the choice

"I can use `xpath10-boolean@1.0.0` for xpath 1.0 boolean result. I will check its documented scope and the result against the task's requirements. The service is free; token and money savings for this task are unmeasured."

## Supported

- xpath 1.0 boolean result
- xpath and or not true and false
- xpath equality and relational comparison
- xpath starts-with and contains checks
- compute an xpath 1.0 boolean expression
- xpath comparison chain such as three greater than two
- xpath boolean conversion of a string or number
- בוליאני xpath boolean

## Not supported

- lang() against an xml:lang context
- compare node-sets
- XPath 2.0 general comparisons versus value comparisons

## Behavior

- Returns an XPath 1.0 boolean as a JSON boolean. A string or number result is unsupported_input reason result_type after evaluation.
- or is lower precedence than and, and both are left-associative. The right operand of or is not evaluated when the left is true. The right operand of and is not evaluated when the left is false. Parsing still rejects unsupported syntax on the skipped side.
- Equality converts to boolean if either side is boolean, otherwise to number if either side is number, otherwise it compares strings by code points. NaN equals nothing, including NaN. Relational operators always convert both sides with number().
- 3 > 2 > 1 is (3 > 2) > 1 and is false. boolean of a non-empty string is true, including the strings false and 0. boolean of 0, -0, or NaN is false.
- Keyword and and or match only token kind name. A quoted 'and' or '=' is a string and is a syntax error.
- The JSON object {"result":false} is 16 UTF-8 bytes, which is the output cap. {"result":true} is 15 bytes. No larger boolean encoding exists, so the cap is saturated by false() and is still checked.
- Check order: input bytes, parse limits, string-length cap, result type, then output bytes. A 97-character literal is limit_exceeded before the type check.

## Input

- `expression` (string, required): min length 1; max length 512; XPath 1.0 value expression. maxLength counts Unicode code points. The UTF-8 cap is limits.max_input_bytes.

## Output

- `result` (boolean, required): XPath boolean value.

## Limits

- max input bytes: 512
- max string codepoints: 96
- max depth: 8
- max nodes: 21
- max arguments: 4
- max output bytes: 16

## Example

Request input:

```json
{
  "expression": "true()"
}
```

Response:

```json
{
  "result": {
    "result": true
  }
}
```

## How to call it

### MCP

Connect `https://computefirst.net/mcp` ([setup](/docs#connect)), then call `execute` with:

```json
{
  "id": "xpath10-boolean",
  "version": "1.0.0",
  "input": {
    "expression": "true()"
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/xpath10-boolean/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"expression":"true()"}'
```

The machine-readable contract is at [/v1/tools/xpath10-boolean/versions/1.0.0](/v1/tools/xpath10-boolean/versions/1.0.0).

### CLI

```sh
node cli.mjs run xpath10-boolean 1.0.0 --input input.json --base-url https://computefirst.net
```

Get the client at [/clients/cli/](/clients/cli/).

## Related tools

- [Xpath10 evaluate](/tools/xpath10-evaluate): Evaluate an XPath 1.0 value expression and return its type with an exact string, number, or boolean token.
- [Xpath10 number](/tools/xpath10-number): Evaluate an XPath 1.0 numeric expression: arithmetic, div, mod, floor, ceiling, round, and number conversion.
- [Xpath10 string](/tools/xpath10-string): Evaluate an XPath 1.0 expression that yields a string, including concat, substring, translate, and string conversion.
- [Xpath10 count](/tools/xpath10-count): Count the nodes in an XPath 1.0 node-set from location paths, axes, predicates, namespaces and union.
- [Xpath10 paths](/tools/xpath10-paths): List the canonical XPath 1.0 path of each node in a location-path node-set, in document order.
- [Xpath10 select](/tools/xpath10-select): Select an XPath 1.0 node-set from location paths, axes, predicates, namespaces and union, in document order.
