histfactory: add write_measurement and patch_xml