XPath Expressions

Last update: Edit

1 Overview

Expressions are used within constraints to generate a value that is true.

There are three types of expressions usable for constraints:

  • Comparisons with operators
  • Functions
  • Exist-expressions

2 Comparisons

A comparison expression consists of two attributes or values separated by a comparison operator like =, <=, and >.

2.1 Examples

For example, this query retrieves all customers whose name is “Jansen”:

//Sales.Customer[Name = 'Jansen']

This query retrieves all the orders for which the total price is less than 50.00 euros:

//Sales.Order[TotalPrice < 50.00]

This query retrieves all customers who have at least one unpaid order:

//Sales.Customer[Sales.Customer_Order/Sales.Order/HasPayed = false()]

This query retrieves all the customers who have the same name as the city they live in:

//Sales.Customer[Name = City]

This query retrieves the customer who placed the order with the given unique identification number:

//Sales.Customer[Sales.Customer_Order = 'ID_124123512341']

The same result can be retrieved by doing the following query:

//Sales.Customer[Sales.Customer_Order/Sales.Order/ID = 'ID_124123512341']

However, it is strongly recommended not to use the notation above. This is because its execution is inefficient and will result in a lower performance due to the manner in which it is processed by the database.

3 Functions

For information on the available functions, see XPath Constraint Functions.

4 Exist-Expressions

The last type of expression is the exist-expression, which can be used to check whether a specific association is filled or not.

4.1 Examples

This query retrieves all the customers who have placed at least one order:


This query retrieves all the customers who have not placed any orders: