1. A method for processing queries, the method comprising the computer-implemented steps of: receiving a certain query, wherein the certain query includes a certain operator to be performed based on a path expression; evaluating the path expression against metadata information that defines the structure of one or more XML documents against which the certain query is to be executed; determining that the path expression evaluates to a plurality of location paths into which the path expression can be expanded, wherein each location path of the plurality of location paths identifies a different XML element within the structure of the one or more XML documents; generating a first representation of the certain query; and rewriting the first representation into a second representation that corresponds to an equivalent query of the certain query, wherein rewriting the first representation comprises: expanding the path expression into the plurality of location paths; and based on the certain operator, including a plurality of operators in the second representation, wherein the plurality of operators include: a first set of operators to be performed based on each of the plurality of location paths, wherein each separate operator in the first set of operators is to be performed on one separate location path of the plurality of location paths; and a second set of operators to be performed based on data that is to be returned from each operator included in the first set of operators; wherein the steps of the method are performed by one or more computer systems.