refactory transform.php and transform_xml.php