A method for processing queries for a document of elements is provided.
The document includes a plurality of subsections where each subsection
includes at least a portion of elements in the document. The method
comprises: receiving a query for a npath of elements in the document of
elements; determining a plurality of step queries from the query, each
step query including at least a part of the path of elements; for each
step query in the plurality of step queries, determining one or more
subsections that include elements that correspond to a step query; and
determining at least one subsection that includes the path of elements of
the query. A result for the query is generated using the at least one
subsection.