We study visibly pushdown automata (VPA) models for expressing and evaluating queries, expressed using MSO formulas, on words with a nesting structure (like XML documents). We define a query VPA model, which is a 2-way deterministic VPA that can mark positions in a document, and show that it is equiexpressive as unary monadic queries. This surprising result parallels a classic result for queries on regular word languages. We also compare our model to query models on unranked trees. We then consider the algorithmic problem of evaluating, in one pass, the set of all positions satisfying a query in a streaming nested word. We present an algorithm that answers any fixed unary monadic query on a streaming document which uses, at any point, at most space O(d+I log n), where d is the depth of the document at that point and I is the number of potential answers to the query in the word processed thus far. This algorithm uses space close to the minimal space any streaming algorithm would need...
P. Madhusudan, Mahesh Viswanathan