Compiling XPath into a State-less Forward-only Subset
Pierre Genev · 2004
We show how the context state of XPath, accessed through the position() and last() pseudo-functions, can be eliminated in most cases by translating references to the context state with an equivalent contextfree expression, and how this enables the use of context state in combination with a subsequent “forward-only” transformation, allowing for execution of (almost) full XPath on any of the emerging “streaming” subsets. Specifically we show how the “normalization” into a “core” language as proposed in the current W3C “Last Call” draft of the XPath/XQuery Formal Semantics can be extended such that the context state and reverse axes can be eliminated from the core XPath (and potentially XQuery) language.