core: refactored transformation code into DocSmithEngine