implement xml pattern-matching