コード例 #1
0
ファイル: XSL.php プロジェクト: jasny/Q
 /**
  * Prepare the transformation
  *
  * @param mixed $data  Data to transform - xml or array or a file that contains the xml or the array
  * @return string
  */
 protected function getCleanedData($data = null)
 {
     if (is_string($data) && !preg_match('/^([\\s|\\t]*(<\\?xml\\s.*\\?>)|(<\\w+>))/i', $data) && !file_exists($data)) {
         throw new Transform_Exception("File '{$data}' doesn't exists.");
     }
     if ($data instanceof Fs_Node) {
         $data = $data->getContents();
     }
     if (is_array($data)) {
         $data = Transform::to('xml', array('rootNodeName' => isset($this->rootNodeName) ? $this->rootNodeName : 'root'))->process($data);
     }
     return $data;
 }