We present a novel, yet simple, technique for the specification of context in structured documents that we call caterpillar
expressions. Although we are applying this technique in the specification of context- dependent style sheets for HTML, XML,
and SGML documents, it is clear that it can be used in other environments such as query specification for structured documents
and for computer program transformations. In addition, we present a number of theoretical results that allow us to compare
the expressive power of caterpillar expressions to that of tree automata.
The work of the three authors was supported partially by a joint DAAD-HK grant. In addition, the work of the third author
was supported under a grant from the Research Grants Council of Hong Kong.