1. A computer system for constructing a query to an XML document, wherein said query is from a client computer and said query contains an element of said XML document, said system comprising: a tree structure generating unit for generating a tree structure; a query rewriting unit for generating an XQuery/XPath for said XML document based on said tree structure and configurable query constraints; a constraint configuring unit for configuring a constraint rule; and a hardware device to execute said tree structure generating unit, said query rewriting unit, and said constraint configuring unit, wherein said element contained in said query from said client computer belongs to said XML document; wherein said XML document can be defined based on an XML schema or can be a schema-less document; and wherein said tree structure generating unit comprises: an extracting unit for extracting (i) a nested relationship between an element of a first XML document and an element of a second XML document; (ii) a nested relationship between an element from a first XML schema and an element from a second XML schema; (iii) a first anchor referred to by said element of said first XML document and a second anchor referred to by said element of said second XML document; and (iv) a nested relationship between said first anchor and said second anchor; a reasoning unit for inferring said tree structure, wherein said element contained in said query from said client computer belongs to said first XML document and said second XML document, based on said nested relationship extracted by said extracting unit; and optionally a relationship repository device for storing (i) said nested relationship between said element of said first XML document and said element of said second XML document and (ii) said nested relationship between said first anchors and said second anchor.