Property Constraint

A query may specify further constraints on the result nodes by way of property constraints.

XPath: In XPath a predicate that tests attributes on the last location step forms the property constraint expression. Predicates on any other location step are optional.

SQL: In SQL the WHERE clause forms the constraint expression.




FROM my:type
WHERE my:title='JSR 170'

//element(*, my:type)
[@my:title = 'JSR 170']

In order to ensure mutual translatability between XPath and SQL we only require support for the XPath general comparison operators (=, !=, <, <=, >, >=). In SQL the semantics of these operators must be the same as they are for XPath. The only difference is that in XPath the not-equal operator is !=, while in SQL it is <>.

The term “general comparison” comes from XPath terminology. The significance of requiring support for XPath general comparison, and their equivalents in SQL, lies in the way that these operators behave with multi-value properties. See Searching Multi-value Properties for details.

Additionally, support for jcr:like() (LIKE in SQL) and jcr:contains (CONTAINS in SQL) is required (though the range of this requirement is qualified below).

Since not all property types can be meaningfully compared using all operators the following describes the minimal set of comparison support required for each property type:

STRING: =, != (<>), <, <=, >, >=, jcr:like()(LIKE)

LONG: =, != (<>), <, <=, >, >=

DOUBLE: =, != (<>), <, <=, >, >=

DATE: =, != (<>), <, <=, >, >=

NAME: =, != (<>)

PATH: =, != (<>), (additionally, in SQL, LIKE is used against the jcr:path pseudo-property to define path constraints, see Path Constraint)

REFERENCE: =, != (<>)

BOOLEAN: =, != (<>)

BINARY: (none)

The jcr:like function in XPath corresponds to the LIKE operator in SQL. See jcr:like Function and LIKE.

Support for the jcr:contains() (CONTAINS() in SQL) function is not required for any property types in particular. It is however required to work at the node level. In that case it applies to those properties of the node for which the implementation maintains an index. Which properties those are is an implementation issue. See jcr:contains Function and CONTAINS.

Support for comparing jcr:score in a SQL WHERE clause or jcr:score(...) in a XPath predicate is not required.

In XPath support is only required for comparisons of the form <property><op><literalvalue> and <literalvalue><op><property>. For example, support for [@p = "hello"] and ["hello" = @p] (and so forth for each operator) is required. Support for [@p = @q] (and so forth for each operator) is not required.




my:title = 'JSR 170'

@my:title = 'JSR 170'

my:title <> 'JSR 170'

@my:title != 'JSR 170'

my:title < 'JSR 170'

@my:title < 'JSR 170'

my:title <= 'JSR 170'

@my:title <= 'JSR 170'

my:title > 'JSR 170'

@my:title > 'JSR 170'

my:title >= 'JSR 170'

@my:title >= 'JSR 170'

my:title = 'JSR 170' AND my:author = 'David'

@my:title = 'JSR 170' and @my:author = 'David'

my:title = 'JSR 170' OR
my:title = 'JSR-170'

@my:title = 'JSR 170' or
@my:title = 'JSR-170'

NOT (my:title = 'JSR 170')

not(@my:title >= 'JSR 170')

my:title IS NOT NULL


my:title IS NULL


my:title LIKE 'JSR 170%'

'JSR 170%')

CONTAINS(*, 'JSR 170')

jcr:contains(., 'JSR 170')