7. The system according to claim 1 , wherein: the matching component is capable of knowing the schema of the XML document and foreseeing the coming discrete pieces of the XML document.
1. A system to process an XML document, comprising: a streaming parser, running on one more processors, adapted to parse an XML document and generate a stream of discrete pieces of the XML document, wherein the XML document is represented using a hierarchical data structure, and each said discrete piece of the document is represented by one or more nodes in the hierarchical data structure; a matching component, operating on the hierarchical data structure, capable of performing the steps of: accepting a discrete piece of the XML document from the stream of discrete pieces from the streaming parser at one time; keeping in memory only said discrete piece of the XML document from the stream at said time; maintaining a plurality of contexts associated with the XML document in a context data structure, wherein each context of the plurality of contexts contains a node in the hierarchical data structure and a position of the node relative to a context node; mapping each context of the plurality of contexts to the stream of discrete pieces of the XML document and performing a match against each context of the plurality of contexts on said discrete piece of the XML document from the stream; and passing the particular discrete piece of the XML document to a user object for handling when the particular discrete piece of the XML document is a matched discrete piece of the XML document.