Rewrite checking selectors/rules against given doc.