--- - name: probability tag: mi match: "(.='P'" replace: - intent: name: "probability" attrs: "id='@id'" children: [x: "text()"] - name: given tag: mo match: "(.='|' and count(preceding-sibling::*)=1 and count(following-sibling::*)=1 and parent::preceding-sibling::*[last()][.='P']" replace: - intent: name: "given" attrs: "id='@id'" children: [x: "text()"]