@Override public void verify() throws TransformException { for (Pair<Node, List<Node>> pair : siblingsByTarget) { Node target = pair.first; List<Node> storedSiblings = pair.second; for (Node sibling : storedSiblings) { if (!target.query().single(".. is $_1/..", sibling).booleanValue()) throw new TransformException( "previously selected node is no longer a sibling: " + sibling); } List<Node> actualSiblings = query.runOn(mod.scope(target.query().single("..").query())).nodes().asList(); if (!actualSiblings.equals(storedSiblings)) throw new TransformException( "sibling list changed for target " + target.query().single("@xml:id").value()); // No need to check sibling order, since any change in the node's document will trigger a // sort. } }