Structure-aware scheme-based document templating