Tree patterns represent important fragments of XPath. In this paper, we show
that some classes C of tree patterns exhibit such a property that, given a finite number of
compatible tree patterns P1, . . . , Pn ∈ C, there exists another pattern P such that P1, . . . , Pn
are all contained in P, and for any tree pattern Q ∈ C, P1, . . . , Pn are all contained in Q if
and only if P is contained in Q.We experimentally demonstrate that the pattern P is usually
much smaller than P1, . . . , Pn combined together. Using the existence of P above, we show
that testing whether a tree pattern, P, is contained in another, Q ∈ C, under an acyclic schema
graph G, can be reduced to testing whether PG, a transformed version of P, is contained in
Q without any schema graph, provided that the distinguished node of P is not labeled *.We
then show that, under G, the maximal contained rewriting (MCR) of a tree pattern Q using
a view V can be found by finding the MCR of Q using VG without G, when there are no
*-nodes on the distinguished path of V and no *-nodes in Q.