Enforce sanity checks on write operations.

Impose some minimal sanity checks on the input root node, including:
 . Its tag name must match with that of the target node;
 . If provided, its href must match with that of the target node,
   regardless of in absolute or relative format.

However, the input root node can safely omit the href attribute
at all, since the target node has been fully specified by the
request URI.