/** * return xml translated by XSL * * @param array $xml_details * @return void * @author Andy Bennett */ function return_translated_template($xml_details) { if (!array_key_exists('xml_debug', $xml_details)) { $xml_details['xml_debug'] = 0; } if (!array_key_exists('xsl_debug', $xml_details)) { $xml_details['xsl_debug'] = 0; } if (!array_key_exists('xslf_debug', $xml_details)) { $xml_details['xslf_debug'] = 0; } if (!isset($xml_details['directory'])) { $xml_details['directory'] = '/'; } $tpath = APPPATH . 'xslt' . $xml_details['directory']; $xsl_file = $tpath . '/' . $xml_details['xsl_file']; if ($xml_details['xslf_debug']) { print_r($xsl_file); } $xml = steam_xml_helper::convert_array_to_xml($xml_details['xml_data'], "result"); if ($xml_details['xml_debug']) { print_r($xml->saveXML()); } $result = self::xslt_return_translated($xml, $xsl_file); if ($xml_details['xsl_debug']) { print_r($result); } return $result; }
/** * decode the passed json into xml * * @param string $json * @return string * @author Andy Bennett */ public static function return_xml_string($json) { // decode the JSON into an associative array $tree = json_decode($json, true); // convert to XML string $xml = steam_xml_helper::convert_array_to_xml($tree, "root"); $s = simplexml_import_dom($xml); $dom = new DOMDocument(); $root = $dom->createElement('root'); $dom->appendChild($root); self::save_parse('items', $dom, $root, $s->items); return $dom->saveXML(); }