1. A method of editing elements of a first document based on elements of a second document, said elements of said first document having a template structure, each said template comprising at least one match condition, said match condition being an expression in said template that describes a subset of nodes that are matched in a tree structure, said second document containing a tree structure to which said matching is applicable, said method comprising: comparing a first selected fragment of an element from said second document with a second selected fragment of an element from said second document to determine if a match condition exists that describes the relation between templates in said first document, said match condition matching said first selected fragment and said second selected fragment; and permitting at least one of a plurality of predefined editing operations on said first document if said match condition exists.