6.6.3.2 Type Constraint

A type constraint specifies the common primary node type of the returned nodes, plus, possibly, additional mixin types that they also must have. Type constraints are inheritance-sensitive in that specifying a constraint of node type X will include all nodes explicitly declared to be type X, as well as all nodes of subtypes of X.

Implementations are required to support constraints of one primary type. It is optional to support constraints based on multiple primary node types (this would, in any case, only be applicable to implementations that supported multiple inheritance of node types). It is also optional to support constraints on (one or more) mixin node types.

Note however, that property constraints can always be used to test declared types (that is, a non-inheritance-sensitive test), by testing the values of the properties jcr:primaryType and jcr:mixinType.(see 6.6.3.3 Property Constraint).

XPath: In XPath the element test is used to test against node type. It is optional to support element tests on location steps other than the last.

SQL: In SQL the type constraint is expressed in the FROM clause.

Examples:

SQL

XPath

SELECT *
FROM my:type

//element(*, my:type)

SELECT *
FROM my:type
WHERE jcr:path LIKE '/nodes[%]/%'

/jcr:root/nodes//
element(*, my:type)