6.6.2 XPath and SQL

XPath 2.0 forms the basis of the querying syntax in level 1. All compliant repository implementations must support this search syntax. However, implementations that use a relational database as an underlying datastore will typically be limited in the range of XPath queries that they can efficiently support. Such implementations will find support for the optional SQL syntax a more natural fit (see 8.5 Searching Repository Content with SQL).

Therefore, in order to ensure that database-backed implementations are not unnecessarily burdened by compliance requirements, only a subset of XPath is required. This subset is defined as the set of XPath statements that can be translated to and from SQL at parse-time of the query.

This arrangement allows database-backed repositories to implement search natively with SQL but still comply with the minimal XPath requirement by translating XPath queries to SQL.

On the other hand, implementations that are natively hierarchical and therefore capable of supporting XPath functionality beyond the minimum requirement are free to do so.

As mentioned, support for SQL is optional. But because the minimal set of XPath features is driven by the semantic range of SQL, a knowledge of the mapping between the two aids greatly in understanding that minimal feature set XPath. The following sections summarize that mapping.