Various query languages have been proposed to extract and restructure information in XML documents. These languages, usually claiming to be declarative, mainly consider the conjunctive relationships among data elements. In order to present the operations where the hierarchical and the disjunctive relationships need to be considered, such as restructuring hierarchy and handling heterogeneity, the programs in these languages often exhibit a procedural style and thus the declarativeness in them is not so prominent as in conventional query languages like SQL.In this paper, we propose a declarative pattern-based functional XML query language named XML Tree Query (XTQ). XTQ adopts expressive composite patterns to present data extraction, meanwhile establishing the conjunctive, the disjunctive and the hierarchical relationships among data elements. It uses the matching terms, a composite structure of the variables bound to the matched data elements, to present a global sketch of the ex-✩ This research is partially supported by National Science Foundation of China and Open Foundation of State Key Lab of Software Engineering.✩✩ The authors wish to thank the anonymous referees for their valuable comments and suggestions, which greatly improved the technical content and the presentation of the paper. Also thanks to Tieyun Qian and Ming Zhong for their valuable advice and efforts in revising the submission.