/**
  * 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;
 }
 /**
  * get the form xml string
  *
  * @return string
  * @author Andy Bennett
  */
 private function get_form_xml_string()
 {
     $path = 'forms/' . $this->setup->form_name;
     // pull the form xml in as a simplexml object
     try {
         $form_xml_string = steam_xml_helper::load_xml_string($path);
     } catch (Exception $e) {
         try {
             // if the form doesn't exist, create one from the database
             $steamform_model = new Steamform_Model();
             $form_xml_string = $steamform_model->get_form_xml($this->setup);
         } catch (Exception $e) {
             throw new Kohana_404_Exception($path);
         }
     }
     return $form_xml_string;
 }
 /**
  * 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();
 }