XPath Operators

Last modified: August 12, 2025

For XPath Query Constraints

The following operators can be used in XPath query constraints, both in Mendix Studio Pro and in Java code:

OperatorDescriptionExampleReturn value
=Equal toprice = 9.80true if price is 9.80, false if price is 9.90
!=Not equal toprice != 9.80true if price is 9.90, false if price is 9.80
<Less thanprice < 9.80true if price is 9.70, false if price is 9.80
<=Less than or equal toprice <= 9.80true if price is 9.80, false if price is 9.90
>Greater thanprice > 9.80true if price is 9.90, false if price is 9.80
>=Greater than or equal toprice >= 9.80true if price is 9.80, false if price is 9.70
orOrprice = 9.80 or price = 9.70true if price is 9.80, false if price is 9.60
andAndprice = 9.80 and amount = 1true if price is 9.80 and amount is 1, false if price is 9.70 and amount is 1, false if price is 9.80 and amount is 2, false if price is 9.70 and amount is 2

Mathematical operators

In Studio Pro, mathematical operators can be used in XPath constraints that are defined in the model such as the Retrieve object(s) microflow activity or access rule constraints.

Mathematical operators are not allowed in queries that come from the client. For example, they cannot be used in widgets.

The following mathematical operators are supported:

OperatorDescriptionExampleReturn value
+Addition6 + 410
-Subtraction6 - 42
*Multiplication6 * 424
divDivision8 div 42

In Java code, mathematical operators are disabled by default for the XPathQuery API, but can be enabled using the allowMathOperators method. For example:

Core.createXPathQuery("//Module.Entity[attr1 + attr2 = 42]")
    .allowMathOperators(true)
    .execute(context);

Operator Behavior

The behavior of operators may differ based on the database type used for your Mendix application. The Mendix runtime generates a SQL query for the XPath you have configured. This query can be interpreted differently by different database types. For example, HSQLDB will ignore trailing spaces when using the = operator, whereas PostgreSQL will take those into consideration.