1. A method for dynamically generating an XQuery for an XML database that stores a plurality of non-XML text documents, each non-XML text document having a corresponding shadow XML document in a collection of shadow XML documents in the XML database, wherein the collection contains the corresponding shadow XML documents on which the XQuery is to be executed, wherein each shadow XML document comprises metadata extracted from the corresponding non-XML text document and wherein the XML database is configured for executing an XQuery on the shadow XML documents and for retrieving corresponding non-XML text documents, the method comprising: providing a FLWOR expression comprising a plurality of units of XQuery code, the plurality of units being predefined based on the non-XML text documents and comprising at least one predefined text retrieval function, wherein the FLWOR expression comprises a for clause predefined based on the shadow XML documents in the collection of shadow XML documents corresponding to the non-XML text documents, wherein the for clause indicates the collection of shadow XML documents and a doctype; combining the one or more units with dynamic input from a user to generate the XQuery, the dynamic input from the user defining a where clause including at least one dynamically defined condition for the XQuery; and storing the XQuery.