With the growing popularity of streaming data model, processing queries over streaming data has become an important topic. Streaming data has received attention in a number of communities, including data mining, theoretical computer science, networking, and grid computing. We believe that streaming data processing involves challenges for compilers, which have not been addressed so far. Particularly, the following two questions are important: – How do we transform queries so that they can be correctly executed with a single pass on streaming data ? – How do we determine when a query, possibly after certain transformations, can be correctly executed with only a single pass on the dataset. In this paper, we address these questions in the context of XML query language, XQuery. Because of XQuery’s single assignment nature and special constructs for dealing with sequences, the above questions can be answered more easily than for a general imperative language. However, we believe our wo...