/** * Do the conversion for a source document * * @param object DOMDocument $sourceDoc * @param string $sourceFilePath * @return DOMDocument The output document * @access public * @since 2/4/08 */ public function convert(DOMDocument $sourceDoc, $sourceFilePath) { $this->sourceDoc = $sourceDoc; $this->sourceXPath = new DOMXPath($this->sourceDoc); if (!is_dir($sourceFilePath)) { throw new Exception("'{$sourceFilePath}' does not exist for conversion."); } if (!is_readable($sourceFilePath)) { throw new Exception("'{$sourceFilePath}' is not readable for conversion."); } $this->sourceFilePath = $sourceFilePath; // Set up the output document $this->doc = new Harmoni_DOMDocument(); $this->doc->appendChild($this->doc->createElement('Segue2')); $this->doc->documentElement->setAttribute('export_date', DateAndTime::now()->asString()); $this->doc->documentElement->setAttribute('segue_version', displayAction::getSegueVersion()); $this->doc->documentElement->setAttribute('segue_export_version', '2.0'); $this->agents = $this->doc->documentElement->appendChild($this->doc->createElement('agents')); $this->xpath = new DOMXPath($this->doc); $this->rootAdded = false; // print "<pre>"; // foreach ($this->sourceXPath->query('/site/media/media_file/filename') as $filename) // print $filename->nodeValue."\n"; // print "</pre>"; $this->addSite(); return $this->doc; }