Regular Paper

The VLDB Journal

, Volume 18, Issue 4, pp 857-883

First online:

Query translation from XPath to SQL in the presence of recursive DTDs

  • Wenfei FanAffiliated withUniversity of EdinburghBell Laboratories Email author 
  • , Jeffrey Xu YuAffiliated withThe Chinese University of Hong Kong
  • , Jianzhong LiAffiliated withHarbin Institute of Technology
  • , Bolin DingAffiliated withThe Chinese University of Hong Kong
  • , Lu QinAffiliated withThe Chinese University of Hong Kong

Rent the article at a discount

Rent now

* Final gross prices may vary according to local VAT.

Get Access


We study the problem of evaluating xpath queries over xml data that is stored in an rdbms via schema-based shredding. The interaction between recursion (descendants-axis) in xpath queries and recursion in dtds makes it challenging to answer xpath queries using rdbms. We present a new approach to translating xpath queries into sql queries based on a notion of extended XP ath expressions and a simple least fixpoint (lfp) operator. Extended xpath expressions are a mild extension of xpath, and the lfp operator takes a single input relation and is already supported by most commercial rdbms. We show that extended xpath expressions are capable of capturing both dtd recursion and xpath queries in a uniform framework. Furthermore, they can be translated into an equivalent sequence of sql queries with the lfp operator. We present algorithms for rewriting xpath queries over a (possibly recursive) dtd into extended xpath expressions and for translating extended xpath expressions to sql queries, as well as optimization techniques. The novelty of our approach consists in its capability to answer a large class of xpath queries by means of only low-end rdbms features already available in most rdbms, as well as its flexibility to accommodate existing relational query optimization techniques. In addition, these translation algorithms provide a solution to query answering for certain (possibly recursive) xml views of xml data. Our experimental results verify the effectiveness of our techniques.


XML database XPath SQL Recursive DTD Query translation