Regular expression pattern matching for XML
Haruo Hosoya, Benjamin C. Pierce · ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL) · 2001
We propose regular expression pattern matching as a core feature for programming languages for manipulating XML (and similar tree-structured data formats). We extend conventional pattern-matching facilities with regular expression operators such as repetition (*), alternation (I), etc., that can match arbitrarily long sequences of subtrees, allowing a compact pattern to extract data from the middle of a complex sequence. We show how to check standard notions of exhaustiveness and redundancy for these patterns.Regular expression patterns are intended to be used in languages whose type systems are also based on the regular expression types. To avoid excessive type annotations, we develop a type inference scheme that propagates type constraints to pattern variables from the surrounding context. The type inference algorithm translates types and patterns into regular tree automata and then works in terms of standard closure operations (union, intersection, and difference) on tree automata. The main technical challenge is dealing with the interaction of repetition and alternation patterns with the first-match policy, which gives rise to subtleties concerning both the termination and the precision of the analysis. We address these issues by introducing a data structure representing closure operations lazily.
Cited by 132 works. doi:10.1145/360204.360209 Open-access PDF
Authors
References
- Introduction to automata theory, languages and computation
- Introduction to automata theory, languages, and computation
- A Extensible Markup Language XML
- Extensible markup language
- J.E.Hopcroft, J.D. Ullman 著, "Introduction to Automata Theory, Languages, and Computation", Addison-Wesley, A5変形版, X+418, \6,670, 1979
- The Definition of Standard ML
- The Lorel query language for semistructured data
- XML-QL: A Query Language for XML
- HOPE
- Anytime, anywhere