/** * Read the content of an existing XMI file. * If the file is UML/XMI 1, a conversion to version 2 is automatically applied. * * @param string $filepath Filename */ public function loadXmi($filepath) { if (empty($this->xmiDocument)) { $this->xmiDocument = new PHP_UML_Output_XmiDocument(); } $this->xmiDocument->load($filepath); }
/** * Implementation of tickFile(): we update the model with the information * found in the XMI file. * * @param string $fileBase Directory path * @param string $filePath File name * * @see PHP_UML/UML/FileScanner#tickFile() */ public function tickFile($fileBase, $filePath) { $filename = $fileBase . $filePath; if (!(file_exists($filename) && is_readable($filename))) { throw new PHP_UML_Exception('Could not read ' . $filename . '.'); } $doc = new DOMDocument(); if (!$doc->load($filename)) { return; } if (PHP_UML_Output_XmiDocument::isVersion1($doc)) { $xmi = PHP_UML_Output_ExporterXSL::convertTo2($doc->saveXML()); $doc->loadXML($xmi); } $builder = new PHP_UML_Input_XMI_Builder(); $builder->setModel($this->model); $builder->buildDom($doc); $this->model = $builder->getModel(); }
/** * Generates output data by applying a transformation on the XMI stored in the * property $xmi * * @param string $outputDir Output folder * * @return DOMDocument A DOM document containing the result of the XSLT */ public function export($outputDir) { $xslFile = $this->getXslFilepath(); if (empty($this->xmiDocument)) { $temp = new PHP_UML_Output_Xmi_Exporter(); /* * Component views and deployment views don't mean anything * for output formats other than XMI. Yet, since ExporterXSL is * a subclass of ExportXMI, we must force these options to * false, otherwise they will appear in the output produced by * the XSL transformation: */ $temp->setComponentView(false); $temp->setDeploymentView(false); $temp->setModel($this->structure); $temp->generateXmi(); $this->xmiDocument = $temp->getXmiDocument(); } if (file_exists($xslFile)) { return $this->exportFromXml($outputDir, $xslFile, $this->xmiDocument->dump()); } else { throw new PHP_UML_Exception('Could not find the XSL template file. It must be named ' . self::STARTING_TPL . ', under Format/YourTemplate/'); } }