Initial Commit

This commit is contained in:
Riley Schneider
2025-12-03 16:38:10 +01:00
parent c5e26bf594
commit b732d8d4b5
17680 changed files with 5977495 additions and 2 deletions

View File

@@ -0,0 +1,65 @@
<?php
/**
* PHP_UML
*
* PHP version 5
*
* @category PHP
* @package PHP_UML
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
* @version SVN: $Revision: 136 $
* @link http://pear.php.net/package/PHP_UML
* @since $Date: 2009-12-10 01:35:58 +0100 (jeu., 10 déc. 2009) $
*/
/**
* This class is a contextual wrapper around a "current" package being
* processed. It is used during the traversal of all the packages of
* a model, especially to store temporarily a complete view about all
* the relationships between the contained types.
*
* @category PHP
* @package PHP_UML
* @subpackage Output
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
*/
class PHP_UML_Output_ApiContextPackage
{
/**
* Filepath to the current package
* @var string
*/
public $dir = '';
/**
* Relative filepath to go to the top package
* @var string
*/
public $rpt = '';
/**
* Classes of the package
* @var array
*/
public $classes;
/**
* Interfaces of the package
* @var array
*/
public $interfaces;
/**
* Datatpyes of the package
* @var array
*/
public $datatypes;
public $allImplemented = array();
public $allImplementing = array();
public $allInherited = array();
public $allInheriting = array();
}
?>

View File

@@ -0,0 +1,373 @@
<?php
/**
* PHP_UML
*
* PHP version 5
*
* @category PHP
* @package PHP_UML
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
* @version SVN: $Revision: -1 $
* @link http://pear.php.net/package/PHP_UML
* @since $Date: $
*/
/**
* Top class for the API "renderers" used by the ExporterAPI implementations
*
* @category PHP
* @package PHP_UML
* @subpackage Output
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
*/
abstract class PHP_UML_Output_ApiRenderer
{
const PACKAGE_FILENAME = 'package-summary';
const CLASS_PREFIX = 'class-';
const INTERFACE_PREFIX = 'interface-';
const DATATYPE_PREFIX = 'datatype-';
const META_INTERFACE = PHP_UML_Metamodel_Superstructure::META_INTERFACE;
const META_CLASS = PHP_UML_Metamodel_Superstructure::META_CLASS;
const META_DATATYPE = PHP_UML_Metamodel_Superstructure::META_DATATYPE;
const META_OPERATION = PHP_UML_Metamodel_Superstructure::META_OPERATION;
const META_PROPERTY = PHP_UML_Metamodel_Superstructure::META_PROPERTY;
const T_NAMESPACE = '\\';
/**
* Main template (we pre-store it to avoid reading repeatedly)
* @var string
*/
protected $mainTpl;
/**
* Classes that won't appear directly in the main API lists
* for readability (even though each one has its own detail page)
* @var array
*/
protected $hiddenClasses = array();
/**
* Hidden interfaces
* @var array
*/
protected $hiddenInterfaces = array();
/**
* Hidden classifiers
* @var array
*/
protected $hiddenClassifiers = array();
/**
* These docblocks will not be displayed in the docblocks list
* @var array
*/
protected $ignoredTag = array();
/**
* Reference to the Exporter object (giving access to the ApiContextPackage)
* @var PHP_UML_Output_ExporterAPI
*/
protected $exporter;
/**
* Render globally a package
*
* @param PHP_UML_Metamodel_Package $p Starting package (model)
*/
abstract function render($p);
/**
* Constructor for an ApiRenderer.
*
* @param PHP_UML_Output_ExporterAPI $exporter Reference to an exporter
*/
public function __construct(PHP_UML_Output_ExporterAPI $exporter)
{
$this->hiddenClasses = array_merge($this->hiddenClasses, PHP_UML_Metamodel_Enumeration::$classes);
$this->hiddenInterfaces = array_merge($this->hiddenInterfaces, PHP_UML_Metamodel_Enumeration::$interfaces);
$this->hiddenClassifiers = array_merge($this->hiddenClassifiers, $this->hiddenClasses);
$this->hiddenClassifiers = array_merge($this->hiddenClassifiers, $this->hiddenInterfaces);
$this->hiddenClassifiers = array_merge($this->hiddenClassifiers, PHP_UML_Metamodel_Enumeration::$datatypes);
$this->exporter = $exporter;
}
abstract protected function getDescription(PHP_UML_Metamodel_Stereotype $s, $annotatedElement='');
/**
* Renders the operation's parameters
*
* @param PHP_UML_Metamodel_Operation $operation The operation
* @param bool $withType If true, adds an hyperlink
*
* @return string
*/
abstract protected function getParameterList(PHP_UML_Metamodel_Operation $operation, $withType = false);
/**
* Renders a default value
*
* @param PHP_UML_Metamodel_TypedElement $obj A property or a parameter
*
* @return string
*/
abstract protected function getDefaultValue(PHP_UML_Metamodel_TypedElement $obj);
/**
* Returns the content of a template file
*
* @param string $str Template filename
*
* @return string The content of the template
*/
protected function getTemplate($str)
{
$baseSrc = $this->getTemplateDirectory();
return file_get_contents($baseSrc.DIRECTORY_SEPARATOR.$str);
}
/**
* Return the current ApiContextPackage object
*
* @return PHP_UML_Output_ApiContextPackage
*/
protected function getContextPackage()
{
return $this->exporter->getContextPackage();
}
static protected function getObjPrefix(PHP_UML_Metamodel_NamedElement $x)
{
switch (get_class($x)) {
case self::META_INTERFACE:
return self::INTERFACE_PREFIX;
case self::META_DATATYPE:
return self::DATATYPE_PREFIX;
case self::META_OPERATION:
return self::PACKAGE_FILENAME;
case self::META_PROPERTY:
return self::PACKAGE_FILENAME;
}
return self::CLASS_PREFIX;
}
static protected function getObjStyle(PHP_UML_Metamodel_NamedElement $x)
{
switch (get_class($x)) {
case self::META_INTERFACE:
return 'interface';
case self::META_DATATYPE:
return 'datatype';
case self::META_OPERATION:
return 'method';
case self::META_PROPERTY:
return 'property';
}
return 'class';
}
/**
* Renders a link to an element
* (since datatypes don't own to a "package", we suppose they are located in
* the top package)
*
* @param PHP_UML_Metamodel_Classifier $t The element
* @param string $cssStyle CSS style to use
*
* @return string
*/
//abstract protected function getLinkTo(PHP_UML_Metamodel_Classifier $t, $cssStyle='link');
/**
* Returns the complete namespace for an element
*
* @param PHP_UML_Metamodel_Classifier $t The classifier
*
* @return string
*/
protected function getQualifiedName(PHP_UML_Metamodel_Classifier $t)
{
$ns = isset($t->package) ? $this->getAbsPath($t->package, self::T_NAMESPACE) : '';
return $ns.$t->name;
}
/**
* Renders an unresolved type
*
* @param string $type Type, provided as a string
*
* @return string
*/
abstract protected function displayUnresolved($type);
/**
* Returns the path from the top package to a given package
*
* @param PHP_UML_Metamodel_Package $p The package
* @param string $delimiter Delimiter
*
* @return string
*/
protected function getAbsPath(PHP_UML_Metamodel_Package $p, $delimiter='/')
{
if (!empty($p->nestingPackage)) {
return $this->getAbsPath($p->nestingPackage, $delimiter).$p->name.$delimiter;
}
else
return '';
}
/**
* Returns the return parameter of a function
*
* @param PHP_UML_Metamodel_Operation $operation The function
*
* @return PHP_UML_Metamodel_Parameter The parameter
*/
protected function getReturnParam(PHP_UML_Metamodel_Operation $operation)
{
foreach ($operation->ownedParameter as $p) {
if ($p->direction=='return') {
return $p;
}
}
return null;
}
/**
* Renders the properties of a given stereotype
*
* @param PHP_UML_Metamodel_Stereotype $s A stereotype
*
* @return string
*/
abstract protected function getTagsAsList(PHP_UML_Metamodel_Stereotype $s);
/**
* Returns the array containing all the extended classes of a classifier
* This array must have been previously set in the Context object
*
* @param PHP_UML_Metamodel_NamedElement $c A classifier or a package
*
* @return array
*/
protected function getAllInherited(PHP_UML_Metamodel_NamedElement $c)
{
return array_key_exists($c->id, $this->getContextPackage()->allInherited) ? $this->getContextPackage()->allInherited[$c->id] : array();
}
/**
* Returns the array containing all the classes that extends a classifier
*
* @param PHP_UML_Metamodel_NamedElement $c A classifier or a package
*
* @return array
*/
protected function getAllInheriting(PHP_UML_Metamodel_NamedElement $c)
{
return array_key_exists($c->id, $this->getContextPackage()->allInheriting) ? $this->getContextPackage()->allInheriting[$c->id] : array();
}
/**
* Returns the array containing all the interfaces of a classifier
*
* @param PHP_UML_Metamodel_NamedElement $c A classifier or a package
*
* @return array
*/
protected function getAllImplemented(PHP_UML_Metamodel_NamedElement $c)
{
return array_key_exists($c->id, $this->getContextPackage()->allImplemented) ? $this->getContextPackage()->allImplemented[$c->id] : array();
}
/**
* Returns the array containing all the classes that implement a given interface
*
* @param PHP_UML_Metamodel_NamedElement $c A classifier or a package
*
* @return array
*/
protected function getAllImplementing(PHP_UML_Metamodel_NamedElement $c)
{
return array_key_exists($c->id, $this->getContextPackage()->allImplementing) ? $this->getContextPackage()->allImplementing[$c->id] : array();
}
/**
* Saves a string in a file (in the folder referenced in the context object)
*
* @param string $elementName Filename (without the extension)
* @param string $str Content
*/
abstract protected function save($elementName, $str);
/**
* Renders the block "Properties" of a package or a class
*
* @param PHP_UML_Metamodel_NamedElement $p A classifier/a package
*
* @return string
*/
abstract protected function getPropertyBlock(PHP_UML_Metamodel_NamedElement $p);
/**
* Returns an ID for a property
*
* @param PHP_UML_Metamodel_Property $o Element
*
* @return string
*/
protected function generatePropertyId(PHP_UML_Metamodel_Property $o)
{
return str_replace('$', '', $o->name);
}
/**
* Returns an ID to identify a function
*
* @param PHP_UML_Metamodel_Operation $o Element
*
* @return string
*/
protected function generateFunctionId(PHP_UML_Metamodel_Operation $o)
{
return 'f'.$o->id;
}
/**
* Renders the block "Function" of a package or a classifier
*
* @param PHP_UML_Metamodel_NamedElement $p A classifier or a package
*
* @return string
*/
abstract protected function getFunctionBlock(PHP_UML_Metamodel_NamedElement $p);
/**
* Renders the "File" information tag
*
* @param PHP_UML_Metamodel_NamedElement $p An element
*
* @return string
*/
abstract protected function getFileInfo(PHP_UML_Metamodel_NamedElement $p);
/**
* Replace the template's placeholders with their value
*
* @param string $main Main content (generated by PHP_UML)
* @param string $nav Navigation content (navig bar)
* @param string $tit Title content
* @param string $name Element name
*
* @return string
*/
abstract protected function replaceInTpl($main, $nav, $tit, $name);
}
?>

View File

@@ -0,0 +1,44 @@
<?php
/**
* PHP_UML (PHP_UML_Output_Eclipse_AbstractBuilder)
*
* PHP version 5
*
* @category PHP
* @package PHP_UML
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
* @version SVN: $Revision: 176 $
* @link http://pear.php.net/package/PHP_UML
* @since $Date: 2011-09-19 00:03:11 +0200 (lun., 19 sept. 2011) $
*/
/**
* Extended abstract class to generate a UML model that can be imported into Eclipse
*
* @category PHP
* @package PHP_UML
* @subpackage Output
* @subpackage Eclipse
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
*/
abstract class PHP_UML_Output_Eclipse_AbstractBuilder extends PHP_UML_Output_Xmi_AbstractBuilder
{
/**
* Factory method. Retrieves a proper implementation class,
* matching the XMI version.
*
* @param float $version XMI version
*
* @return PHP_UML_Output_Xmi_Builder An XMI builder object
*/
static function getInstance($version)
{
if ($version < 2)
return new PHP_UML_Output_Xmi_BuilderImpl1($xmlEncoding);
else
return new PHP_UML_Output_Eclipse_BuilderImpl2($xmlEncoding);
}
}
?>

View File

@@ -0,0 +1,68 @@
<?php
/**
* PHP_UML (PHP_UML_Output_Eclipse_BuilderImpl2)
*
* PHP version 5
*
* @category PHP
* @package PHP_UML
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
* @version SVN: $Revision: 176 $
* @link http://pear.php.net/package/PHP_UML
* @since $Date: 2011-09-19 00:03:11 +0200 (lun., 19 sept. 2011) $
*/
/**
* Implementation class to create XMI in version 2, adapted for importation into Eclipse
*
* See the interface PHP_UML_Output_Eclipse_Builder for the comments.
*
* @category PHP
* @package PHP_UML
* @subpackage Output
* @subpackage Xmi
* @see PHP_UML_Output_Xmi_Builder
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
*/
class PHP_UML_Output_Eclipse_BuilderImpl2 extends PHP_UML_Output_Xmi_BuilderImpl2
{
const XMI_VERSION = '2.1';
const UML_VERSION = '2.1.2';
const DEFAULT_CLASSIFIER_ATT = ' visibility="public" ';
public function getXmiHeaderOpen()
{
return '';
}
public function getModelOpen(PHP_UML_Metamodel_Package $model)
{
return '<uml:Model xmi:type="uml:Model" name="'.$model->name.'"
xmi:version="2.1" xmlns:xmi="http://schema.omg.org/spec/XMI/2.1"
xmlns:uml="http://www.eclipse.org/uml2/2.1.0/UML"
xmi:id="'.$model->id.'" '.self::DEFAULT_CLASSIFIER_ATT.'>';
}
public function getXmiHeaderClose()
{
return '';
}
public function getRealizations(PHP_UML_Metamodel_Class $client)
{
$str = '';
foreach ($client->implements as &$rclass) {
if (is_object($rclass)) {
$str .= '<packagedElement xmi:type="uml:Realization" '.
'xmi:id="'.self::getUID().'" '.
'client="'.$client->id.'" '.
'supplier="'.$rclass->id.'" />';
}
}
return $str;
}
}
?>

View File

@@ -0,0 +1,44 @@
<?php
/**
* PHP_UML
*
* PHP version 5
*
* @category PHP
* @package PHP_UML
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
* @version SVN: $Revision: 176 $
* @link http://pear.php.net/package/PHP_UML
* @since $Date: 2011-09-19 00:03:11 +0200 (lun., 19 sept. 2011) $
*/
/**
* This class generates a specific XMI file that can be imported into Eclipse
*
* @category PHP
* @package PHP_UML
* @subpackage Output
* @subpackage Xmi
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
*/
class PHP_UML_Output_Eclipse_Exporter extends PHP_UML_Output_Xmi_Exporter
{
/**
* Getter for the XMI factory. Overrides the parent.
*
*/
protected function getXmiBuilder()
{
$builder = PHP_UML_Output_Eclipse_AbstractBuilder::getInstance($this->xmiVersion);
$builder->setEncoding($this->encoding);
$builder->setLogicalView($this->logicalView);
$builder->setComponentView($this->componentView);
$builder->setDeploymentView($this->deploymentView);
$builder->setStereotypes(false);
return $builder;
}
}
?>

View File

@@ -0,0 +1,93 @@
<?php
/**
* PHP_UML
*
* PHP version 5
*
* @category PHP
* @package PHP_UML
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
* @version SVN: $Revision: 179 $
* @link http://pear.php.net/package/PHP_UML
* @since $Date: 2011-09-19 16:09:54 +0200 (lun., 19 sept. 2011) $
*/
/**
* This class is a set of various data/switches that can be used by the
* implementations of the exporter
*
* @category PHP
* @package PHP_UML
* @subpackage Output
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
*/
abstract class PHP_UML_Output_Exporter
{
const APP_NAME = 'PHP_UML';
/**
* A UML model
* @var PHP_UML_Metamodel_Superstructure
*/
protected $structure;
/**
* Constructor
*
* @param string $format Usual format name
*/
public function __construct()
{
}
/**
* Setter for the model.
*
* @param PHP_UML_Metamodel_Superstructure $model A UML model
*/
public function setModel(PHP_UML_Metamodel_Superstructure $model)
{
$this->structure = $model;
}
/**
* Export the current model to a particular output format.
*
* @param string $outDir Directory where the resulting output must be stored
*/
abstract public function export($outDir);
/**
* Factory method to retrieve an implementation of an exporter, given the "common name" of
* a format.
*
* @param string $format Common name of the desired export format
*
* @return PHP_UML_Output_Exporter
*/
static function getInstance($format)
{
if (empty($format))
$format = 'xmi';
$format = strtolower($format);
$ucf = ucfirst($format);
if ($ucf == "Htmlnew")
$ucf = "HtmlNew";
$className = 'PHP_UML_Output_'.$ucf.'_Exporter';
if (!class_exists($className)) {
throw new PHP_UML_Exception('Unknown export format: "'.$format.'"');
}
$instance = new $className();
return $instance;
}
}
?>

View File

@@ -0,0 +1,143 @@
<?php
/**
* PHP_UML
*
* PHP version 5
*
* @category PHP
* @package PHP_UML
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
* @version SVN: $Revision: 169 $
* @link http://pear.php.net/package/PHP_UML
* @since $Date: 2011-09-12 01:28:43 +0200 (lun., 12 sept. 2011) $
*/
/**
* This is the exportation class relying on the API (= on the full hierarchy of
* metaclasses stored in the model). Note that another way to export a model would
* be to use ExporterXSL, which is based on an XSL transformation of XMI.
* A class implementing ExporterAPI must reside in a subfolder containing a class
* named PHP_UML_<name of the output format>_Exporter. This class must also have a
* public method "generate", which is used to start the serialization process.
*
* @category PHP
* @package PHP_UML
* @subpackage Output
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
*/
abstract class PHP_UML_Output_ExporterAPI extends PHP_UML_Output_Exporter
{
/**
* Object storing some contextual data
*
* @var PHP_UML_Output_ApiContextPackage
*/
protected $ctx;
public function export($outDir)
{
if (!file_exists($outDir))
throw new PHP_UML_Exception('Export directory ('.$outDir.') does not exist.');
if (empty($this->structure) || empty($this->structure->packages)) {
throw new PHP_UML_Exception('No model to export');
}
}
/**
* Return the ApiContextPackage currently associated to the rendering
*
* @return PHP_UML_Output_ApiContextPackage
*/
public function getContextPackage()
{
return $this->ctx;
}
/**
* Sets the allInherited/-ing arrays with all the classifiers that a given
* classifier inherits from
*
* @param PHP_UML_Metamodel_Classifier $s The initial reference classifier
* @param PHP_UML_Metamodel_Classifier $t The current classifier to check
*/
protected function setAllInherited(PHP_UML_Metamodel_Classifier $s, PHP_UML_Metamodel_Classifier $t)
{
if (!empty($t->superClass) && is_object($t->superClass[0])) {
$h = $t->superClass[0];
$this->setAllInherited($s, $h);
$this->ctx->allInherited[$s->id][] = $h;
$this->ctx->allInheriting[$h->id][] = $s;
}
}
/**
* Sets the allImplemented/-ing arrays with all the interfaces that a given
* class implements (including those of the inherited classes)
*
* @param PHP_UML_Metamodel_Class $s The initial reference class
* @param PHP_UML_Metamodel_Classifier $t The current classifier to check
*/
protected function setAllImplemented(PHP_UML_Metamodel_Class $s, PHP_UML_Metamodel_Classifier $t)
{
if (!empty($t->superClass) && is_object($t->superClass[0])) {
$this->setAllImplemented($s, $t->superClass[0]);
}
if (isset($t->implements) && is_array($t->implements)) {
foreach ($t->implements as $impl) {
if (is_object($impl)) {
$this->setAllImplemented($s, $impl);
$this->ctx->allImplemented[$s->id][] = $impl;
$this->ctx->allImplementing[$impl->id][] = $s;
}
}
}
}
/**
* Recurses into all the packages to build a list of all the generalizations
* and realizations between elements.
* We normally do this before creating the detailed files.
*
* @param PHP_UML_Metamodel_Package $pkg Starting package
*/
protected function setAllSuperClassifiers(PHP_UML_Metamodel_Package $pkg)
{
foreach ($pkg->ownedType as $type) {
switch (get_class($type)) {
case PHP_UML_Metamodel_Superstructure::META_CLASS:
$this->setAllImplemented($type, $type);
case PHP_UML_Metamodel_Superstructure::META_INTERFACE:
$this->setAllInherited($type, $type);
}
}
foreach ($pkg->nestedPackage as $np) {
$this->setAllSuperClassifiers($np);
}
}
protected function initContextPackage(PHP_UML_Metamodel_Package $pkg, $dir, $rpt)
{
$this->ctx->classes = array();
$this->ctx->interfaces = array();
$this->ctx->datatypes = array();
$this->ctx->dir = $dir;
$this->ctx->rpt = $rpt;
foreach ($pkg->ownedType as $type) {
switch (get_class($type)) {
case PHP_UML_Metamodel_Superstructure::META_INTERFACE:
$this->ctx->interfaces[] = $type;
break;
case PHP_UML_Metamodel_Superstructure::META_DATATYPE:
$this->ctx->datatypes[] = $type;
break;
default:
$this->ctx->classes[] = $type;
}
}
}
}
?>

View File

@@ -0,0 +1,317 @@
<?php
/**
* PHP_UML
*
* PHP version 5
*
* @category PHP
* @package PHP_UML
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
* @version SVN: $Revision: 176 $
* @link http://pear.php.net/package/PHP_UML
* @since $Date: 2011-09-19 00:03:11 +0200 (lun., 19 sept. 2011) $
*/
/**
* An exportation class, that relies on XSL transformations.
*
* It does its export by transforming the XMI data contained in the object
* $xmiDocument.
* Various transformations are available: they are all stored in separate subfolders
* (php, html). To get an ExporterXSL for a given format, call the constructor
* with the name of the format as first parameter:
* new PHP_UML_Output_ExporterXSL("php")
* This format name must be equal to the folder name where the desired XSL files are.
*
* @category PHP
* @package PHP_UML
* @subpackage Output
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
* @link http://pear.php.net/package/PHP_UML
*/
abstract class PHP_UML_Output_ExporterXSL extends PHP_UML_Output_Exporter
{
const RESOURCES_FOLDER = 'resources';
const STARTING_TPL = 'main.xsl';
protected $saveToFileCallback;
protected $createFolderCallback;
/**
* XmiDocument object containing the XMI to transform
*
* @var PHP_UML_Output_XmiDocument
*/
protected $xmiDocument;
public function __construct()
{
parent::__construct();
$this->saveToFileCallback = __CLASS__.'::saveToFile';
$this->createFolderCallback = __CLASS__.'::createFolder';
}
public function setSaveToFileCallback($function)
{
$this->saveToFileCallback = $function;
}
public function setCreateFolderCallback($function)
{
$this->createFolderCallback = $function;
}
/**
* Generates output data by applying a transformation on a given XMI file
*
* @param string $outputDir Output directory
* @param string $xslFile XSL file (template file)
* @param string $xmlFile XMI file
*/
protected function exportFromFile($outputDir, $xslFile, $xmlFile)
{
if (is_file($xmlFile) && is_readable($xmlFile)) {
$xmlDom = new DomDocument;
$xmlDom->load($xmlFile);
return $this->transform($outputDir, $xslFile, $xmlDom);
} else {
throw new PHP_UML_Exception(
'Could not read file '.$xmlFile
);
}
}
/**
* Generates ouput data by applying a transformation on some provided XMI
*
* @param string $outputDir Output directory
* @param string $xslFile XSL file (template file)
* @param string $xmlData The XMI data
*/
protected function exportFromXml($outputDir, $xslFile, $xmlData)
{
if (empty($xmlData))
throw new PHP_UML_Exception(
'No XMI data was available for transformation.'
);
$xmlDom = new DomDocument;
$xmlDom->loadXML($xmlData);
return $this->transform($outputDir, $xslFile, $xmlDom);
}
/**
* Return the absolute location of the XSL file
*
* @return string Filepath
*/
abstract function getXslFilepath();
/**
* 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/'
);
}
}
/**
* Generates output data by applying a transformation on a Dom Document
*
* @param string $outputDir Output folder
* @param string $xslFile XSL file (template file)
* @param DomDocument $xmlDom XMI data (Dom)
*
* @return string (possible) messages raised during XSLT
*/
private function transform($outputDir, $xslFile, DomDocument $xmlDom)
{
clearstatcache();
$userCurrentDir = getcwd(); // we memorize the current working dir
chdir(dirname(__FILE__)); // ... swap to the /Output dir
if ($xslFile=='')
$xslFile = 'html/'.self::STARTING_TPL;
if (!(file_exists($xslFile) && is_readable($xslFile)))
throw new PHP_UML_Exception(
'Could not read file '.$xslFile
);
$xslDom = new DomDocument;
$xslDom->load($xslFile); // ... load the XSLT starting file
chdir($userCurrentDir); // ... and change back to the user dir
// so that we can check the output dir (counted from the user dir)
if ($outputDir=='')
throw new PHP_UML_Exception(
'No output directory was given.'
);
if (!file_exists($outputDir))
throw new PHP_UML_Exception(
'Directory '.$outputDir.' does not exist.'
);
chdir($outputDir);
self::copyResources(dirname($xslFile));
$xslProc = new XSLTProcessor;
$xslProc->registerPHPFunctions();
$xslProc->importStylesheet($xslDom);
$xslProc->setParameter('', 'phpSaveToFile', $this->saveToFileCallback);
$xslProc->setParameter('', 'phpCreateFolder', $this->createFolderCallback);
$xslProc->setParameter('', 'appName', self::APP_NAME);
$xslProc->setParameter('', 'genDate', date('r'));
$out = $xslProc->transformToDoc($xmlDom);
chdir($userCurrentDir); // ... and back again to the original user dir
return $out;
}
const XMLNS_UML1 = 'http://www.omg.org/spec/UML/1.4';
/**
* XMI converter
*
* @param string $xmi XMI (in version 1)
*
* @return string XMI (in version 2)
*/
static public function convertTo2($xmi)
{
return self::simpleTransform('xmi1to2.xsl', $xmi);
}
/**
* Applies a simple transformation on XML data
* Used by the UML 1->2 conversion
*
* @param string $xsl XSL file
* @param string $xmi XML data
*
* @return string XML
*/
static private function simpleTransform($xsl, $xmi)
{
//we must set the xmlns:UML to the same value as the XSLT stylesheet
//(otherwise transfomations don't work)
$xmi = preg_replace('/xmlns:(UML)\s*=\s*["\'](.*)["\']/i', 'xmlns:$1="'.self::XMLNS_UML1.'"', $xmi, 1);
$xslDom = new DomDocument;
$xslDom->load(dirname(__FILE__).DIRECTORY_SEPARATOR.$xsl);
$xmlDom = new DomDocument;
$xmlDom->loadXML($xmi);
/* $xmiTag = &$xmlDom->getElementsByTagName('XMI')->item(0);
if ($xmiTag->getAttribute('xmlns:UML') != '') {
$xmlDom->getElementsByTagName('XMI')->item(0)->setAttribute('verified', 'http://www.omg.org/spec/UML/1.4');
} */
$xslProc = new XSLTProcessor;
$xslProc->importStylesheet($xslDom);
$xslProc->setParameter('', 'appName', self::APP_NAME);
return $xslProc->transformToXML($xmlDom);
}
/**
* Copy the "resources" folder
*
* @param string $path Path to the folder that contains the XSL templates
*/
static private function copyResources($path)
{
$dir = $path.DIRECTORY_SEPARATOR.self::RESOURCES_FOLDER;
if (file_exists($dir)) {
$iterator = new DirectoryIterator($dir);
foreach ($iterator as $file) {
if($file->isFile())
copy($file->getPathname(), $file->getFilename());
}
}
}
/**
* Create a folder. This is a callback function for the XSL templates
* (that's why it is public), and you should not have to use it.
*
* @param string $path Folder name
*/
static public function createFolder($path)
{
if (substr(getcwd(), -1)==DIRECTORY_SEPARATOR)
$k = getcwd().utf8_decode($path);
else
$k = getcwd().DIRECTORY_SEPARATOR.utf8_decode($path);
if (!file_exists($k)) {
mkdir($k);
}
chdir($k);
}
/**
* Save a content to a file. This is a callback function for the XSL templates
* (that's why it is public), and you should not have to use it.
*
* @param string $name File name
* @param mixed $content Content (can be either a string, or a node-set)
*/
static public function saveToFile($name, $content)
{
$file = fopen(utf8_decode($name), 'w');
if (is_string($content)) {
fwrite($file, utf8_decode($content));
} else {
$dom = new DomDocument();
$node = $dom->importNode($content[0], true);
$dom->appendChild($node);
fwrite($file, $dom->saveHTML());
}
fclose($file);
}
}
?>

View File

@@ -0,0 +1,34 @@
<?php
/**
* PHP_UML
*
* PHP version 5
*
* @category PHP
* @package PHP_UML
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
* @version SVN: $Revision: 178 $
* @link http://pear.php.net/package/PHP_UML
* @since $Date: 2011-09-19 03:08:06 +0200 (lun., 19 sept. 2011) $
*/
/**
* Implementation of an exporter to generate an HTML website (Javadoc look and
* feel)
*
* @category PHP
* @package PHP_UML
* @subpackage Output
* @subpackage Html
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
*/
class PHP_UML_Output_Html_Exporter extends PHP_UML_Output_ExporterXSL
{
function getXslFilepath()
{
return dirname(__FILE__).DIRECTORY_SEPARATOR.self::STARTING_TPL;
}
}
?>

View File

@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" exclude-result-prefixes="uml xmi"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:uml="http://schema.omg.org/spec/UML/2.1.2"
xmlns:xmi="http://schema.omg.org/spec/XMI/2.1">
<!-- Called on the top container. Lists all the "uml:Package" elements, in the left frame. -->
<xsl:template name="allclasses">
<html>
<xsl:call-template name="htmlStartPage"/>
<xsl:call-template name="htmlHead">
<xsl:with-param name="path" />
<xsl:with-param name="title" select="concat(@name,' - All Classes')"/>
</xsl:call-template>
<body>
<div id="contentFrame">
<h1>All Classes</h1>
<ul>
<xsl:for-each select="//packagedElement[@xmi:type='uml:Class' or @xmi:type='uml:Interface' or @xmi:type='uml:DataType']">
<xsl:sort select="@name" data-type="text" case-order="lower-first"/>
<xsl:variable name="prefix">
<xsl:call-template name="getPackageFilePath">
<xsl:with-param name="context" select="."/>
</xsl:call-template>
<xsl:call-template name="getPrefix">
<xsl:with-param name="context" select="."/>
</xsl:call-template>
</xsl:variable>
<li>
<xsl:if test="@xmi:type='uml:Interface'">
<xsl:attribute name="class">interfaceElement</xsl:attribute>
</xsl:if>
<a href="{concat('./', $prefix, @name, '.html')}" target="classFrame">
<xsl:value-of select="@name"/>
</a>
</li>
</xsl:for-each>
</ul>
</div>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

View File

@@ -0,0 +1,452 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" exclude-result-prefixes="uml xmi exslt exslt-set exslt-functions"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:uml="http://schema.omg.org/spec/UML/2.1.2"
xmlns:xmi="http://schema.omg.org/spec/XMI/2.1"
xmlns:exslt="http://exslt.org/common" xmlns:exslt-set="http://exslt.org/sets"
xmlns:exslt-functions="http://exslt.org/functions">
<!-- Called on every class/interface. One file per class/interface -->
<xsl:template name="classifier">
<xsl:param name="relPathTop"/>
<xsl:param name="entity"/>
<xsl:param name="nestingPackageName"/>
<xsl:param name="ownedAttributeSet"/>
<xsl:param name="ownedOperationSet" />
<xsl:param name="generalization"/>
<xsl:param name="implements"/>
<xsl:param name="prevEntity"/>
<xsl:param name="nextEntity"/>
<xsl:param name="filePrefix"/>
<xsl:param name="relPathClass"/>
<xsl:variable name="path">
<element>
<xsl:attribute name="id"><xsl:value-of select="@xmi:id"/></xsl:attribute>
<xsl:call-template name="getPackageNamePart"/>
<xsl:value-of select="@name"/>
</element>
<xsl:for-each select="generalization">
<xsl:call-template name="generalization"></xsl:call-template>
</xsl:for-each>
</xsl:variable>
<xsl:variable name="allImplementedClasses" select="key('getElementById', key('getRealizations', exslt:node-set($path)/*/@id)/@supplier)"/>
<xsl:variable name="allImplementingClasses" select="key('getElementById',key('getRealizingClasses', @xmi:id)/@client)"/>
<xsl:variable name="allSubClasses" select="key('getSubclasses', @xmi:id)"/>
<xsl:variable name="artifact" select="key('getElementById',key('getManifestation', @xmi:id)/@client)"/>
<xsl:variable name="lcEntityName" select="translate($entity, 'CDI', 'cdi')"/>
<html>
<xsl:call-template name="htmlStartPage"/>
<xsl:call-template name="htmlHead">
<xsl:with-param name="path" select="$relPathTop"/>
<xsl:with-param name="title" select="concat($nestingPackageName, $packageDelimiter, @name)"/>
</xsl:call-template>
<body>
<div id="navigation">
<div id="banner">
<ul class="sections">
<li><a href="{$relPathTop}{$fileOverviewSummary}" title="Summary of all packages">Overview</a></li>
<li><a href="{$filePackageSummary}" title="Summary of {$nestingPackageName}">Package</a></li>
<li class="active"><xsl:value-of select="$entity"/></li>
<li><a href="{$relPathTop}{$fileIndexAll}">Index</a></li>
</ul>
<ul class="navigFrame">
<a href="{concat($relPathTop,$fileIndex,'?',$relPathClass,$filePrefix,@name,'.html')}" class="navigFrameElem" target="_top">FRAMES</a>
<xsl:text>&#32;</xsl:text>
<a href="{concat($filePrefix,@name,'.html')}" class="navigFrameElem" target="_top">NO FRAMES</a>
</ul>
</div>
<ul class="siblingSections">
<xsl:if test="$prevEntity!=''">
<li><a href="{concat($filePrefix,$prevEntity,'.html')}"><xsl:value-of select="concat('Prev ', $entity)" /></a></li>
</xsl:if>
<xsl:if test="$nextEntity!=''">
<li class="last"><a href="{concat($filePrefix,$nextEntity,'.html')}"><xsl:value-of select="concat('Next ', $entity)" /></a></li>
</xsl:if>
</ul>
</div>
<div id="content">
<div class="classSummary">
<!-- Class Name -->
<h3 id="entityPackage"><xsl:value-of select="$nestingPackageName"/></h3>
<h1 id="entityName"><xsl:value-of select="concat($entity, '&#160;', @name)" /></h1>
<!-- Class tree -->
<xsl:call-template name="htmlInheritedClassTree">
<xsl:with-param name="path" select="$path"/>
<xsl:with-param name="relPathTop" select="$relPathTop"/>
</xsl:call-template>
<!-- All Implemented Classes -->
<xsl:if test="count($allImplementedClasses) &gt; 0">
<h3 class="titleSmallList">All Implemented Interfaces:</h3>
<div class="smallList">
<xsl:for-each select="$allImplementedClasses">
<xsl:call-template name="htmlLinkToElement">
<xsl:with-param name="relPathTop" select="$relPathTop"/>
<xsl:with-param name="context" select="."/>
<xsl:with-param name="style" select="string('linkSimple')"/>
</xsl:call-template>
<xsl:if test="position() &lt; last()"><xsl:text>, </xsl:text></xsl:if>
</xsl:for-each>
</div>
</xsl:if>
<!-- All Implemented Classes -->
<xsl:if test="count($allSubClasses) &gt; 0">
<h3 class="titleSmallList">Direct Known Subclasses:</h3>
<div class="smallList">
<xsl:for-each select="$allSubClasses">
<xsl:call-template name="htmlLinkToElement">
<xsl:with-param name="relPathTop" select="$relPathTop"/>
<xsl:with-param name="context" select="."/>
<xsl:with-param name="style" select="string('linkSimple')"/>
</xsl:call-template>
<xsl:if test="position() &lt; last()"><xsl:text>, </xsl:text></xsl:if>
</xsl:for-each>
</div>
</xsl:if>
<!-- All Implementing Classes -->
<xsl:if test="count($allImplementingClasses) &gt; 0">
<h3 class="titleSmallList">All Known Implementing Classes:</h3>
<div class="smallList">
<xsl:for-each select="$allImplementingClasses">
<xsl:call-template name="htmlLinkToElement">
<xsl:with-param name="relPathTop" select="$relPathTop"/>
<xsl:with-param name="context" select="."/>
<xsl:with-param name="style" select="string('linkSimple')"/>
</xsl:call-template>
<xsl:if test="position() &lt; last()"><xsl:text>, </xsl:text></xsl:if>
</xsl:for-each>
</div>
</xsl:if>
<hr/>
<!-- Class details -->
<xsl:text>public&#160;</xsl:text>
<xsl:if test="@isAbstract='true' and $entity!='Interface'">
<xsl:text>abstract&#160;</xsl:text>
</xsl:if>
<xsl:value-of select="concat($lcEntityName, '&#160;')"/>
<strong><xsl:value-of select="@name" /></strong><br/>
<xsl:if test="count($generalization) &gt; 0">
extends <xsl:value-of select="$generalization/@name" /><br/>
</xsl:if>
<xsl:if test="count($implements) &gt; 0">
implements
<xsl:for-each select="$implements">
<xsl:value-of select="@name" />
<xsl:if test="position() &lt; last()">,&#160;</xsl:if>
</xsl:for-each>
</xsl:if>
<p>
<xsl:call-template name="htmlDescription">
<xsl:with-param name="baseElement" select="@xmi:id"/>
</xsl:call-template>
<xsl:if test="count($artifact) &gt; 0">
<b>File: </b>
<xsl:for-each select="exslt:node-set($artifact)/ancestor::*[@xmi:type='uml:Package']">
<xsl:if test="position() &gt; 1"><xsl:value-of select="concat('/',@name)"/></xsl:if>
</xsl:for-each>
<xsl:value-of select="concat('/', $artifact/@name)"/>
</xsl:if>
</p>
<hr/>
</div>
<xsl:if test="count($ownedAttributeSet) &gt; 0">
<div id="fieldSummary">
<h2>Field Summary</h2>
<table border="1" class="tableSummary">
<xsl:for-each select="$ownedAttributeSet">
<xsl:call-template name="class-field-summary">
<xsl:with-param name="relPathTop" select="$relPathTop"/>
</xsl:call-template>
</xsl:for-each>
</table>
</div>
</xsl:if>
<xsl:if test="count($ownedOperationSet) &gt; 0">
<div id="methodSummary">
<h2>Method Summary</h2>
<table border="1" class="tableSummary">
<xsl:for-each select="$ownedOperationSet">
<xsl:call-template name="class-method-summary">
<xsl:with-param name="relPathTop" select="$relPathTop"/>
</xsl:call-template>
</xsl:for-each>
</table>
</div>
</xsl:if>
<xsl:if test="count($ownedAttributeSet) &gt; 0">
<div id="fieldDetail">
<h2>Field Detail</h2>
<xsl:for-each select="$ownedAttributeSet">
<xsl:call-template name="class-field-detail">
<xsl:with-param name="relPathTop" select="$relPathTop"/>
</xsl:call-template>
</xsl:for-each>
</div>
</xsl:if>
<xsl:if test="count($ownedOperationSet) &gt; 0">
<div id="methodDetail">
<h2>Method Detail</h2>
<xsl:for-each select="$ownedOperationSet">
<xsl:call-template name="class-method-detail">
<xsl:with-param name="relPathTop" select="$relPathTop"/>
<xsl:with-param name="specifiedBy" select="exslt:node-set($allImplementedClasses)/ownedOperation[@name=current()/@name]"/>
</xsl:call-template>
</xsl:for-each>
</div>
</xsl:if>
<xsl:variable name="nestedClassSet" select="nestedClassifier[@xmi:type='uml:Class']"/>
<xsl:if test="count($nestedClassSet) &gt; 0">
<div>
<h2>Nested Classes</h2>
<xsl:call-template name="htmlTableSummary">
<xsl:with-param name="relPathTop" select="$relPathTop"/>
<xsl:with-param name="set" select="$nestedClassSet"/>
<xsl:with-param name="filePrefix" select="string(concat(@name, '/', $fileprefixClass))"/>
</xsl:call-template>
</div>
</xsl:if>
</div>
</body>
</html>
</xsl:template>
<xsl:template name="class-field-summary">
<xsl:param name="relPathTop"/>
<tr>
<td align="right" width="1%" valign="top">
<span class="code">
<xsl:choose>
<xsl:when test="@isReadOnly='true'">const</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="@visibility='private'">private</xsl:when>
<xsl:when test="@visibility='protected'">protected</xsl:when>
</xsl:choose>
<xsl:if test="@isStatic='true'">&#160;static</xsl:if>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="count(type) &gt; 0">
<xsl:text>&#160;</xsl:text>
<xsl:call-template name="htmlType">
<xsl:with-param name="relPathTop" select="$relPathTop"/>
<xsl:with-param name="context" select="."/>
</xsl:call-template>
</xsl:if>
</span>
</td>
<td valign="top">
<span class="code">
<a href="#{@name}" class="linkSummary"><xsl:value-of select="@name" /></a>
</span>
</td>
</tr>
</xsl:template>
<!-- Method summary -->
<xsl:template name="class-method-summary">
<xsl:param name="relPathTop"/>
<tr>
<td align="right" width="1%" valign="top">
<span class="code">
<xsl:if test="@isReadOnly='true'">final</xsl:if>
<xsl:choose>
<xsl:when test="@visibility='private'">&#160;private</xsl:when>
<xsl:when test="@visibility='protected'">&#160;protected</xsl:when>
</xsl:choose>
<xsl:if test="@isAbstract='true'">&#160;abstract</xsl:if>
<xsl:if test="@isStatic='true'">&#160;static</xsl:if>
<xsl:choose>
<xsl:when test="ownedParameter[@direction='return']">
<xsl:text>&#160;</xsl:text>
<xsl:call-template name="htmlType">
<xsl:with-param name="relPathTop" select="$relPathTop"/>
<xsl:with-param name="context" select="ownedParameter[@direction='return']"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise/>
</xsl:choose>
</span>
</td>
<td valign="top">
<span class="code">
<xsl:variable name="parameters">
<xsl:call-template name="htmlParametersBracket">
<xsl:with-param name="relPathTop" select="$relPathTop"/>
</xsl:call-template>
</xsl:variable>
<a href="#{concat(@name,$parameters)}" class="linkSummary"><xsl:value-of select="@name"/></a>
<xsl:copy-of select="$parameters"/>
</span>
</td>
</tr>
</xsl:template>
<!-- Field Detail -->
<xsl:template name="class-field-detail">
<xsl:param name="relPathTop"/>
<div class="detail" id="{@name}">
<h4><xsl:value-of select="@name" /></h4>
<div class="detailContent">
<span class="code">
<xsl:choose>
<xsl:when test="@isReadOnly='true'">const</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="@visibility='private'">private</xsl:when>
<xsl:when test="@visibility='protected'">protected</xsl:when>
<xsl:otherwise>public</xsl:otherwise>
</xsl:choose>
<xsl:if test="@isStatic='true'">&#160;static</xsl:if>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="count(type) &gt; 0">
<xsl:text>&#160;</xsl:text>
<xsl:call-template name="htmlType">
<xsl:with-param name="relPathTop" select="$relPathTop"/>
<xsl:with-param name="context" select="."/>
</xsl:call-template>
</xsl:if>
<b><xsl:value-of select="concat(' ', @name)" /></b>
<xsl:if test="defaultValue">
<xsl:value-of select="concat(' = ', defaultValue/@value)" />
</xsl:if>
</span>
<p>
<xsl:call-template name="htmlDescription">
<xsl:with-param name="baseElement" select="@xmi:id"/>
</xsl:call-template>
</p>
</div>
</div>
<hr/>
</xsl:template>
<!-- Method Detail -->
<xsl:template name="class-method-detail">
<xsl:param name="relPathTop"/>
<xsl:param name="specifiedBy"/>
<xsl:variable name="artifact" select="key('getElementById',key('getManifestation', @xmi:id)/@client)"/>
<xsl:variable name="parameters">
<xsl:call-template name="htmlParametersBracket">
<xsl:with-param name="relPathTop" select="$relPathTop"/>
</xsl:call-template>
</xsl:variable>
<div class="detail" id="{concat(@name,$parameters)}">
<h4><xsl:value-of select="@name"/></h4>
<div class="detailContent">
<span class="code">
<xsl:choose>
<xsl:when test="@visibility='private'">private</xsl:when>
<xsl:when test="@visibility='protected'">protected</xsl:when>
<xsl:otherwise>public</xsl:otherwise>
</xsl:choose>
<xsl:if test="@isAbstract='true'">&#160;abstract</xsl:if>
<xsl:if test="@isStatic='true'">&#160;static</xsl:if>
<xsl:choose>
<xsl:when test="ownedParameter[@direction='return']">
<xsl:text>&#160;</xsl:text>
<xsl:call-template name="htmlType">
<xsl:with-param name="relPathTop" select="$relPathTop"/>
<xsl:with-param name="context" select="ownedParameter[@direction='return']"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise/>
</xsl:choose>
<b><xsl:value-of select="concat(' ', @name)" /></b>
<xsl:copy-of select="$parameters"/>
</span>
<!-- Description and tags -->
<p>
<xsl:call-template name="htmlDescriptionParam">
<xsl:with-param name="baseElement" select="@xmi:id"/>
</xsl:call-template>
<xsl:if test="count($artifact) &gt; 0">
<b>File: </b>
<xsl:for-each select="exslt:node-set($artifact)/ancestor::*[@xmi:type='uml:Package']">
<xsl:if test="position() &gt; 1"><xsl:value-of select="concat('/',@name)"/></xsl:if>
</xsl:for-each>
<xsl:value-of select="concat('/', $artifact/@name)"/>
</xsl:if>
</p>
<!-- Specified By -->
<xsl:if test="count($specifiedBy) &gt; 0">
<xsl:for-each select="exslt:node-set($specifiedBy)/ownedComment">
<h3 class="titleSmallList">Description Copied From interface:</h3>
<div class="smallList">
<xsl:value-of select="@body"/>
<xsl:call-template name="br-replace">
<xsl:with-param name="str" select="body/text()"/>
</xsl:call-template>
</div>
</xsl:for-each>
<h3 class="titleSmallList">Specified By</h3>
<div class="smallList">
<xsl:for-each select="$specifiedBy">
<xsl:variable name="classParent" select="parent::*"/>
<xsl:variable name="path">
<xsl:call-template name="getPackageFilePath">
<xsl:with-param name="context" select="$classParent"/>
</xsl:call-template>
<xsl:call-template name="getPrefix">
<xsl:with-param name="context" select="$classParent"/>
</xsl:call-template>
</xsl:variable>
<span class="code">
<a href="{concat($relPathTop,$path,$classParent/@name,'.html#',@name,$parameters)}" class="$linkType">
<xsl:value-of select="@name"/>
</a>
</span>
<xsl:text> in </xsl:text>
<span class="code">
<xsl:call-template name="htmlLinkToElement">
<xsl:with-param name="relPathTop" select="$relPathTop"/>
<xsl:with-param name="context" select="$classParent"/>
<xsl:with-param name="style" select="string('linkSimple')"/>
</xsl:call-template>
</span>
</xsl:for-each>
</div>
</xsl:if>
<xsl:variable name="params" select="ownedParameter[not(@direction) or @direction!='return']"/>
<xsl:if test="count($params) &gt; 0">
<h3 class="titleSmallList">Parameters</h3>
<div class="smallList">
<xsl:variable name="id" select="@xmi:id"/>
<xsl:for-each select="$params">
<xsl:variable name="cnt" select="position()"/>
<span class="code"><xsl:value-of select="@name"/></span>
<xsl:text> - </xsl:text>
<xsl:for-each select="key('getMetadata', $id)/*[local-name()='param'][$cnt]">
<xsl:call-template name="htmlDocblockParam"/>
</xsl:for-each>
<br/>
</xsl:for-each>
</div>
</xsl:if>
</div>
</div>
</xsl:template>
</xsl:stylesheet>

View File

@@ -0,0 +1,239 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" exclude-result-prefixes="uml xmi exslt exslt-set exslt-functions"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:uml="http://schema.omg.org/spec/UML/2.1.2"
xmlns:xmi="http://schema.omg.org/spec/XMI/2.1"
xmlns:exslt="http://exslt.org/common" xmlns:exslt-set="http://exslt.org/sets"
xmlns:exslt-functions="http://exslt.org/functions">
<!-- Common templates required by the documentation exporter -->
<!-- Returns the generalized elements of the current context (through <element> tags)-->
<xsl:template name="generalization">
<xsl:variable name="parent" select="key('getElementById', @general)"/>
<element>
<xsl:attribute name="href">
<xsl:call-template name="getPackageFilePath">
<xsl:with-param name="context" select="$parent"/>
</xsl:call-template>
<xsl:call-template name="getPrefix">
<xsl:with-param name="context" select="$parent"/>
</xsl:call-template>
<xsl:value-of select="concat($parent/@name,'.html')"/>
</xsl:attribute>
<xsl:attribute name="id">
<xsl:value-of select="$parent/@xmi:id"/>
</xsl:attribute>
<xsl:call-template name="getPackageNamePart">
<xsl:with-param name="context" select="$parent"/>
</xsl:call-template>
<xsl:value-of select="$parent/@name"/>
</element>
<xsl:for-each select="$parent/generalization">
<xsl:call-template name="generalization"/>
</xsl:for-each>
</xsl:template>
<xsl:template name="htmlHead">
<xsl:param name="path"/>
<xsl:param name="title"/>
<xsl:comment><xsl:value-of select="concat('Generated&#32;by&#32;',$appName,'&#32;on&#32;',$genDate)"/></xsl:comment>
<head>
<title><xsl:value-of select="$title"/></title>
<link rel="stylesheet" type="text/css" media="all" href="{concat($path,'style.css')}" />
</head>
</xsl:template>
<xsl:template name="htmlInherit">
<xsl:param name="relPathTop" />
<img src="{concat($relPathTop, 'inherit.gif')}" alt="extended by "/>
</xsl:template>
<!-- Displays the inheritance-tree of the current class -->
<xsl:template name="htmlInheritedClassTree">
<xsl:param name="path"/>
<xsl:param name="relPathTop" />
<xsl:variable name="nbElement" select="count(exslt:node-set($path)/*)"/>
<xsl:if test="$nbElement &gt; 1"> <!-- no display if the class does not inherit from anything -->
<dl class="classTree">
<xsl:for-each select="exslt:node-set($path)/*">
<xsl:sort select="position()" data-type="number" order="descending"/>
<dd>
<xsl:choose>
<xsl:when test="position() &gt; 1">
<xsl:if test="position() = last()">
<xsl:attribute name="class">currentElem</xsl:attribute>
</xsl:if>
<xsl:attribute name="style"><xsl:value-of select="concat('padding-left:',(position()-1)*30,'px')"/></xsl:attribute>
<xsl:call-template name="htmlInherit">
<xsl:with-param name="relPathTop" select="$relPathTop"/>
</xsl:call-template>
</xsl:when>
</xsl:choose>
<xsl:choose>
<xsl:when test="position() &lt; $nbElement">
<a href="{concat($relPathTop, @href)}"><xsl:value-of select="text()"/></a>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="text()"/>
</xsl:otherwise>
</xsl:choose>
</dd>
</xsl:for-each>
</dl>
</xsl:if>
</xsl:template>
<xsl:template name="htmlStartPage">
<xsl:attribute name="xmlns">http://www.w3.org/1999/xhtml</xsl:attribute>
<xsl:attribute name="xml:lang">en</xsl:attribute>
<xsl:attribute name="lang">en</xsl:attribute>
</xsl:template>
<xsl:template name="htmlTableSummary">
<xsl:param name="relPathTop"/>
<xsl:param name="set" />
<xsl:param name="filePrefix" />
<table border="1" class="tableSummary">
<xsl:for-each select="$set">
<tr>
<td><strong><a href="{concat($filePrefix, @name, '.html')}"><xsl:value-of select="@name"/></a></strong></td>
<td><xsl:call-template name="titleComment"/></td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
<!-- Displays the parameters of a function as a bracketed list (<ownedParameter...) -->
<xsl:template name="htmlParametersBracket">
<xsl:param name="relPathTop" />
<xsl:text>(</xsl:text>
<xsl:for-each select="ownedParameter[@direction!='return' or not(@direction)]">
<xsl:call-template name="htmlType">
<xsl:with-param name="relPathTop" select="$relPathTop"/>
<xsl:with-param name="context" select="."/>
</xsl:call-template>
<xsl:if test="@direction='inout'">&#38;</xsl:if>
<xsl:value-of select="@name" />
<xsl:if test="defaultValue">
<xsl:value-of select="concat('=', defaultValue/@value)"/>
</xsl:if>
<xsl:if test="position() &lt; last()">
<xsl:text>,&#160;</xsl:text>
</xsl:if>
</xsl:for-each>
<xsl:text>)</xsl:text>
</xsl:template>
<!-- Displays a type as a hyperlink (<type xmi:idref="..."/>) -->
<xsl:template name="htmlType">
<xsl:param name="relPathTop" />
<xsl:param name="context" />
<xsl:variable name="idref" select="$context/type/@xmi:idref | $context/@type"/>
<xsl:if test="$idref!=''">
<xsl:variable name="typeElement" select="key('getElementById', $idref)"/>
<xsl:call-template name="htmlLinkToElement">
<xsl:with-param name="relPathTop" select="$relPathTop"/>
<xsl:with-param name="context" select="$typeElement"/>
</xsl:call-template>
<xsl:text> </xsl:text>
</xsl:if>
</xsl:template>
<!-- Displays the description/docblocks about a given element -->
<xsl:template name="htmlDescription">
<xsl:param name="baseElement"/>
<xsl:variable name="docblocks" select="key('getMetadata', $baseElement)/*[local-name()!='param' and local-name()!='return' and local-name()!='access' and local-name()!='var']"/>
<xsl:for-each select="ownedComment">
<xsl:value-of select="@body"/>
<xsl:call-template name="br-replace">
<xsl:with-param name="str" select="body/text()"/>
</xsl:call-template>
<div>
<xsl:for-each select="$docblocks">
<xsl:call-template name="htmlDocblock"/>
</xsl:for-each>
</div>
</xsl:for-each>
</xsl:template>
<!-- Displays the description/params. Used for method parameters detailing -->
<xsl:template name="htmlDescriptionParam">
<xsl:param name="baseElement"/>
<xsl:variable name="docblocks" select="key('getMetadata', $baseElement)/*[local-name()='param' or local-name()='return']"/>
<xsl:for-each select="ownedComment">
<p>
<xsl:value-of select="@body"/>
<xsl:call-template name="br-replace">
<xsl:with-param name="str" select="body/text()"/>
</xsl:call-template>
</p>
</xsl:for-each>
</xsl:template>
<!-- Displays a docblock element (in general) -->
<xsl:template name="htmlDocblock">
<b>
<xsl:call-template name="toUpperCase">
<xsl:with-param name="str" select="substring(local-name(),1,1)"/>
</xsl:call-template>
<xsl:value-of select="concat(substring(local-name(),2), ':&#32;')"/></b>
<xsl:value-of select="text()"/>
<xsl:copy-of select="*"/><br/>
</xsl:template>
<!-- Displays a docblock param -->
<xsl:template name="htmlDocblockParam">
<xsl:value-of select="substring-after(substring-after(text(), ' '), ' ')"/>
<xsl:copy-of select="*"/>
</xsl:template>
<!-- Replace breaklines by <br/> -->
<xsl:template name="br-replace">
<xsl:param name="str"/>
<xsl:choose>
<xsl:when test="contains($str,$cr)">
<xsl:value-of select="substring-before($str,$cr)"/>
<br/>
<xsl:call-template name="br-replace">
<xsl:with-param name="str" select="substring-after($str,$cr)"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$str"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="htmlLinkToElement">
<xsl:param name="relPathTop" />
<xsl:param name="context" />
<xsl:param name="style" select="string('linkType')"/>
<xsl:variable name="path">
<xsl:call-template name="getPackageFilePath">
<xsl:with-param name="context" select="$context"/>
</xsl:call-template>
<xsl:call-template name="getPrefix">
<xsl:with-param name="context" select="$context"/>
</xsl:call-template>
</xsl:variable>
<a href="{concat($relPathTop,$path,$context/@name,'.html')}" class="{$style}"><xsl:value-of select="$context/@name"/></a>
</xsl:template>
</xsl:stylesheet>

View File

@@ -0,0 +1,176 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" exclude-result-prefixes="uml xmi php exslt exslt-set exslt-functions"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:uml="http://schema.omg.org/spec/UML/2.1.2"
xmlns:xmi="http://schema.omg.org/spec/XMI/2.1"
xmlns:php="http://php.net/xsl"
xmlns:exslt="http://exslt.org/common" xmlns:exslt-set="http://exslt.org/sets"
xmlns:exslt-functions="http://exslt.org/functions">
<xsl:variable name="packageDelimiter">\</xsl:variable>
<xsl:variable name="fileprefixDatatype">datatype-</xsl:variable>
<xsl:variable name="fileprefixClass">class-</xsl:variable>
<xsl:variable name="fileprefixInterface">interface-</xsl:variable>
<xsl:variable name="fileAllclassesFrame">allclasses-frame.html</xsl:variable>
<xsl:variable name="fileOverviewFrame">overview-frame.html</xsl:variable>
<xsl:variable name="fileOverviewSummary">overview-summary.html</xsl:variable>
<xsl:variable name="filePackageFrame">package-frame.html</xsl:variable>
<xsl:variable name="filePackageSummary">package-summary.html</xsl:variable>
<xsl:variable name="fileIndex">index.html</xsl:variable>
<xsl:variable name="fileIndexAll">index-all.html</xsl:variable>
<xsl:variable name="cr" select="'&#xa;'"/>
<xsl:include href="../common.xsl"/>
<xsl:template name="top-container">
<xsl:call-template name="inner-container">
<xsl:with-param name="relPathTop" />
</xsl:call-template>
<xsl:variable name="containerSet" select="//packagedElement[@xmi:type='uml:Package' or @xmi:type='uml:Model']"/>
<!-- Generation of the overview-summary file -->
<xsl:variable name="contentOverviewSummary">
<xsl:call-template name="overview-summary">
<xsl:with-param name="containerSet" select="$containerSet" />
</xsl:call-template>
</xsl:variable>
<xsl:copy-of select="php:function($phpSaveToFile, $fileOverviewSummary, exslt:node-set($contentOverviewSummary)/*)" />
<!-- Generation of the overview-frame file -->
<xsl:variable name="contentOverviewFrame">
<xsl:call-template name="overview-frame">
<xsl:with-param name="containerSet" select="$containerSet" />
</xsl:call-template>
</xsl:variable>
<xsl:copy-of select="php:function($phpSaveToFile, $fileOverviewFrame, exslt:node-set($contentOverviewFrame)/*)" />
<!-- Generation of the allclasses file -->
<xsl:variable name="contentAllclasses">
<xsl:call-template name="allclasses" />
</xsl:variable>
<xsl:copy-of select="php:function($phpSaveToFile, $fileAllclassesFrame, exslt:node-set($contentAllclasses)/*)" />
<!-- Generation of the index file -->
<xsl:variable name="contentIndex">
<xsl:call-template name="index" />
</xsl:variable>
<xsl:copy-of select="php:function($phpSaveToFile, $fileIndex, exslt:node-set($contentIndex)/*)" />
<!-- Generation of the index-all file -->
<xsl:variable name="contentIndexAll">
<xsl:call-template name="index-all" />
</xsl:variable>
<xsl:copy-of select="php:function($phpSaveToFile, $fileIndexAll, exslt:node-set($contentIndexAll)/*)" />
</xsl:template>
<!-- Tree walking of containers (uml package/model) -->
<xsl:template name="inner-container">
<xsl:param name="relPathTop" /> <!-- relative path to root -->
<!-- Misc initializations -->
<xsl:variable name="interfaceSet" select="packagedElement[@xmi:type='uml:Interface']" />
<xsl:variable name="classSet" select="packagedElement[@xmi:type='uml:Class']"/>
<xsl:variable name="ownedOperationSet" select="ownedOperation"/>
<xsl:variable name="ownedAttributeSet" select="ownedAttribute"/>
<xsl:variable name="packageNamePart">
<xsl:call-template name="getPackageNamePart"/>
</xsl:variable>
<!-- Generation of the package-summary file -->
<xsl:variable name="contentSummary">
<xsl:call-template name="package-summary">
<xsl:with-param name="relPathTop" select="$relPathTop"/>
<xsl:with-param name="interfaceSet" select="$interfaceSet"/>
<xsl:with-param name="classSet" select="$classSet"/>
<xsl:with-param name="ownedAttributeSet" select="$ownedAttributeSet"/>
<xsl:with-param name="ownedOperationSet" select="$ownedOperationSet"/>
<xsl:with-param name="packageNamePart" select="$packageNamePart"/>
</xsl:call-template>
</xsl:variable>
<xsl:copy-of select="php:function($phpSaveToFile, $filePackageSummary, exslt:node-set($contentSummary)/*)" />
<!-- Generation of the package-frame files -->
<xsl:variable name="contentFrame">
<xsl:call-template name="package-frame">
<xsl:with-param name="relPathTop" select="$relPathTop"/>
<xsl:with-param name="interfaceSet" select="$interfaceSet"/>
<xsl:with-param name="classSet" select="$classSet"/>
<xsl:with-param name="ownedOperationSet" select="$ownedOperationSet"/>
<xsl:with-param name="ownedAttributeSet" select="$ownedAttributeSet"/>
<xsl:with-param name="packageNamePart" select="$packageNamePart"/>
</xsl:call-template>
</xsl:variable>
<xsl:copy-of select="php:function($phpSaveToFile, $filePackageFrame, exslt:node-set($contentFrame)/*)" />
<!-- Generation of the classifier files -->
<xsl:call-template name="generateClassifierFiles">
<xsl:with-param name="relPathTop" select="$relPathTop" />
<xsl:with-param name="setEntities" select="(packagedElement|nestedClassifier)[@xmi:type='uml:Interface' or @xmi:type='uml:Class' or @xmi:type='uml:DataType']"/>
</xsl:call-template>
<!-- Recursion into the owned containers -->
<xsl:for-each select="packagedElement[@xmi:type='uml:Package' or @xmi:type='uml:Model']">
<!-- Creation of folders -->
<xsl:copy-of select="php:function($phpCreateFolder, string(@name))" />
<xsl:call-template name="inner-container">
<xsl:with-param name="relPathTop" select="concat($relPathTop, '../')"/>
</xsl:call-template>
<xsl:copy-of select="php:functionString('chdir', '../')" />
</xsl:for-each>
</xsl:template>
<!-- Classifier entities handler -->
<xsl:template name="generateClassifierFiles">
<xsl:param name="relPathTop"/>
<xsl:param name="setEntities"/>
<xsl:for-each select="$setEntities">
<xsl:variable name="entity" select="substring-after(@xmi:type,':')"/>
<xsl:variable name="xmiType" select="@xmi:type"/>
<xsl:variable name="filePrefix">
<xsl:call-template name="getPrefix"/>
</xsl:variable>
<xsl:variable name="content">
<xsl:call-template name="classifier">
<xsl:with-param name="relPathTop" select="$relPathTop" />
<xsl:with-param name="entity" select="$entity"/>
<xsl:with-param name="nestingPackageName">
<xsl:call-template name="getNestingPackageName">
<xsl:with-param name="context" select="."/>
</xsl:call-template>
</xsl:with-param>
<xsl:with-param name="ownedAttributeSet" select="ownedAttribute"/>
<xsl:with-param name="ownedOperationSet" select="ownedOperation"/>
<xsl:with-param name="generalization" select="key('getElementById',generalization/@general)"/>
<xsl:with-param name="implements" select="key('getElementById', key('getRealizations', current()/@xmi:id)/@supplier)"/>
<xsl:with-param name="prevEntity" select="preceding-sibling::packagedElement[@xmi:type=$xmiType][1]/@name"/>
<xsl:with-param name="nextEntity" select="following-sibling::packagedElement[@xmi:type=$xmiType][1]/@name"/>
<xsl:with-param name="filePrefix" select="$filePrefix"/>
<xsl:with-param name="relPathClass">
<xsl:call-template name="getPackageFilePath">
<xsl:with-param name="context" select="."/>
</xsl:call-template>
</xsl:with-param>
</xsl:call-template>
</xsl:variable>
<xsl:copy-of select="php:function($phpSaveToFile, string(concat($filePrefix, @name, '.html')), exslt:node-set($content)/*)" />
<!-- nested entities ? -->
<xsl:variable name="setNestedEntities" select="(packagedElement|nestedClassifier)[@xmi:type='uml:Interface' or @xmi:type='uml:Class' or @xmi:type='uml:DataType']"/>
<xsl:if test="count($setNestedEntities) &gt; 0">
<xsl:copy-of select="php:function($phpCreateFolder, string(@name))" />
<xsl:call-template name="generateClassifierFiles">
<xsl:with-param name="relPathTop" select="concat('../', $relPathTop)"/>
<xsl:with-param name="setEntities" select="$setNestedEntities"/>
</xsl:call-template>
<xsl:copy-of select="php:functionString('chdir', '../')" />
</xsl:if>
</xsl:for-each>
</xsl:template>
<xsl:template match="xmi:Documentation"/>
</xsl:stylesheet>

View File

@@ -0,0 +1,173 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" exclude-result-prefixes="uml xmi exslt exslt-set exslt-functions"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:uml="http://schema.omg.org/spec/UML/2.1.2"
xmlns:xmi="http://schema.omg.org/spec/XMI/2.1"
xmlns:exslt="http://exslt.org/common" xmlns:exslt-set="http://exslt.org/sets"
xmlns:exslt-functions="http://exslt.org/functions">
<!-- Called on the top container. Lists all elements -->
<xsl:template name="index-all">
<html>
<xsl:call-template name="htmlStartPage"/>
<xsl:call-template name="htmlHead">
<xsl:with-param name="path" />
<xsl:with-param name="title" select="concat(@name,' - Overview')"/>
</xsl:call-template>
<body>
<div id="navigation">
<div id="banner">
<ul class="sections">
<li><a href="{$fileOverviewSummary}" title="Summary of all packages">Overview</a></li>
<li>Package</li>
<li>Class</li>
<li class="active">Index</li>
</ul>
<ul class="navigFrame">
<a href="{concat($fileIndex,'?',$fileIndexAll)}" class="navigFrameElem" target="_top">FRAMES</a>
<a href="{$fileIndexAll}" class="navigFrameElem" target="_top">NO FRAMES</a>
</ul>
</div>
</div>
<div id="content">
<ul>
<xsl:variable name="content">
<xsl:call-template name="indexAllInnerContainer" mode="indexAll"/>
</xsl:variable>
<xsl:for-each select="exslt:node-set($content)/*">
<xsl:sort select="text()"/>
<li><a href="{@href}"><xsl:value-of select="text()"/></a>
&#32;-&#32;
<xsl:value-of select="comment/text()"/>
<xsl:copy-of select="comment/a"/>
</li>
</xsl:for-each>
</ul>
</div>
</body>
</html>
</xsl:template>
<xsl:template name="indexAllInnerContainer">
<xsl:for-each select="packagedElement[@xmi:type='uml:Package' or @xmi:type='uml:Model']">
<xsl:variable name="setEntities" select="(packagedElement|nestedClassifier)[@xmi:type='uml:Interface' or @xmi:type='uml:Class' or @xmi:type='uml:DataType']"/>
<xsl:for-each select="$setEntities">
<xsl:variable name="entityName" select="@name"/>
<xsl:variable name="path">
<xsl:call-template name="getPackageFilePath">
<xsl:with-param name="context" select="."/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="fileName">
<xsl:value-of select="$path"/>
<xsl:call-template name="getPrefix"><xsl:with-param name="context" select="."/></xsl:call-template>
<xsl:value-of select="concat(@name, '.html')"/>
</xsl:variable>
<xsl:variable name="packageName">
<xsl:call-template name="getPackageNamePart"/>
</xsl:variable>
<li>
<xsl:attribute name="href">
<xsl:value-of select="$fileName"/>
</xsl:attribute>
<comment>
Class in
<a href="{concat($path, $filePackageSummary)}"><xsl:value-of select="$packageName"/></a>
<xsl:text>&#32;</xsl:text>
<xsl:call-template name="titleComment"/>
</comment>
<xsl:value-of select="@name"/>
</li>
<xsl:for-each select="ownedAttribute">
<li>
<xsl:attribute name="href">
<xsl:value-of select="concat($fileName, '#', @name)"/>
</xsl:attribute>
<comment>
Variable in
<xsl:value-of select="$packageName"/><a href="{$fileName}"><xsl:value-of select="$entityName"/></a>
<xsl:text>&#32;</xsl:text>
<xsl:call-template name="titleComment"/>
</comment>
<xsl:value-of select="@name"/>
</li>
</xsl:for-each>
<xsl:for-each select="ownedOperation">
<li>
<xsl:variable name="parameters">
<xsl:call-template name="htmlParametersBracket"/>
</xsl:variable>
<xsl:attribute name="href">
<xsl:value-of select="concat($fileName, '#', @name, $parameters)"/>
</xsl:attribute>
<comment>
Method in
<xsl:value-of select="$packageName"/><a href="{$fileName}"><xsl:value-of select="$entityName"/></a>
<xsl:text>&#32;</xsl:text>
<xsl:call-template name="titleComment"/>
</comment>
<xsl:value-of select="@name"/>
</li>
</xsl:for-each>
</xsl:for-each>
<xsl:call-template name="indexAllInnerContainer"/>
</xsl:for-each>
<!-- procedural elements -->
<xsl:variable name="entityName" select="@name"/>
<xsl:variable name="path">
<xsl:call-template name="getPackageFilePath">
<xsl:with-param name="context" select="."/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="fileName">
<xsl:value-of select="$path"/>
<xsl:choose>
<xsl:when test="@xmi:type='uml:Model'">
<xsl:value-of select="$fileOverviewSummary"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat(@name, '/', $filePackageSummary)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:for-each select="ownedOperation">
<li>
<xsl:variable name="parameters">
<xsl:call-template name="htmlParametersBracket"/>
</xsl:variable>
<xsl:attribute name="href">
<xsl:value-of select="concat($fileName, '#', @name, $parameters)"/>
</xsl:attribute>
<comment>
Method in
<a href="{$fileName}"><xsl:value-of select="$entityName"/></a>
<xsl:text>&#32;</xsl:text>
<xsl:call-template name="titleComment"/>
</comment>
<xsl:value-of select="@name"/>
</li>
</xsl:for-each>
<xsl:for-each select="ownedAttribute">
<li>
<xsl:attribute name="href">
<xsl:value-of select="concat($fileName, '#', @name)"/>
</xsl:attribute>
<comment>
Constant in
<a href="{$fileName}"><xsl:value-of select="$entityName"/></a>
<xsl:text>&#32;</xsl:text>
<xsl:call-template name="titleComment"/>
</comment>
<xsl:value-of select="@name"/>
</li>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

View File

@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" exclude-result-prefixes="uml xmi"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:uml="http://schema.omg.org/spec/UML/2.1.2"
xmlns:xmi="http://schema.omg.org/spec/XMI/2.1">
<xsl:template name="index">
<xsl:param name="containerName" select="@name"/>
<html>
<xsl:call-template name="htmlStartPage"/>
<xsl:call-template name="htmlHead">
<xsl:with-param name="path" />
<xsl:with-param name="title" select="concat($containerName, '&#32;API&#32;Documentation')"/>
</xsl:call-template>
<script type="text/javascript">
<![CDATA[
targetPage = "" + window.location.search;
if (targetPage != "" && targetPage != "undefined")
targetPage = targetPage.substring(1);
function loadFrames() {
if (targetPage != "" && targetPage != "undefined")
top.classFrame.location = top.targetPage;
}
]]>
</script>
<frameset cols="20%,80%" title="" onLoad="top.loadFrames()">
<frameset rows="30%,70%" title="" onLoad="top.loadFrames()">
<frame src="overview-frame.html" name="packageListFrame" title="All Packages" />
<frame src="allclasses-frame.html" name="packageFrame" title="All classes and interfaces (except non-static nested types)" />
</frameset>
<frame src="overview-summary.html" name="classFrame" title="Package, class and interface descriptions" scrolling="yes" />
<noframes>
<h2>Frame Alert</h2>
<p>
This document is designed to be viewed using the frames feature.
If you see this message, you are using a non-frame-capable web client.<br/>
Link to<a HREF="overview-summary.html">Non-frame version.</a>
</p>
</noframes>
</frameset>
</html>
</xsl:template>
</xsl:stylesheet>

View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- The starting template -->
<xsl:include href="documentation-generator.xsl"/>
<!-- Some common templates for documentation generation -->
<xsl:include href="documentation-common.xsl"/>
<!-- The user templates -->
<xsl:include href="classifier.xsl"/>
<xsl:include href="package-summary.xsl"/>
<xsl:include href="overview-summary.xsl"/>
<xsl:include href="overview-frame.xsl"/>
<xsl:include href="allclasses-frame.xsl"/>
<xsl:include href="package-frame.xsl"/>
<xsl:include href="index.xsl"/>
<xsl:include href="index-all.xsl"/>
</xsl:stylesheet>

View File

@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" exclude-result-prefixes="uml xmi"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:uml="http://schema.omg.org/spec/UML/2.1.2"
xmlns:xmi="http://schema.omg.org/spec/XMI/2.1">
<!-- Called on the top container. Lists all the container elements, in the left frame -->
<xsl:template name="overview-frame">
<xsl:param name="containerSet" />
<html>
<xsl:call-template name="htmlStartPage"/>
<xsl:call-template name="htmlHead">
<xsl:with-param name="path" />
<xsl:with-param name="title" select="concat(@name,' - Overview')"/>
</xsl:call-template>
<body>
<div id="contentFrame">
<a href="{$fileAllclassesFrame}" target="packageFrame">All Classes</a>
<h3>Packages</h3>
<ul>
<xsl:for-each select="$containerSet">
<li>
<xsl:variable name="path">
<xsl:call-template name="getPackageFilePath">
<xsl:with-param name="context" select="."/>
</xsl:call-template>
<xsl:value-of select="@name"/>
</xsl:variable>
<a href="{concat('./', $path, '/', $filePackageFrame)}" target="packageFrame">
<xsl:call-template name="getPackageNamePart"/>
<xsl:value-of select="@name"/>
</a>
</li>
</xsl:for-each>
</ul>
</div>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

View File

@@ -0,0 +1,144 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" exclude-result-prefixes="uml xmi"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:uml="http://schema.omg.org/spec/UML/2.1.2"
xmlns:xmi="http://schema.omg.org/spec/XMI/2.1">
<!-- Called on the top container. Lists all the container elements (packages) -->
<xsl:template name="overview-summary">
<xsl:param name="containerSet"/>
<html>
<xsl:call-template name="htmlStartPage"/>
<xsl:call-template name="htmlHead">
<xsl:with-param name="path" />
<xsl:with-param name="title" select="concat(@name,' - Overview')"/>
</xsl:call-template>
<body>
<div id="navigation">
<div id="banner">
<ul class="sections">
<li class="active">Overview</li>
<li>Package</li>
<li>Class</li>
<li><a href="{$fileIndexAll}">Index</a></li>
</ul>
<ul class="navigFrame">
<a href="{concat($fileIndex,'?',$fileOverviewSummary)}" class="navigFrameElem" target="_top">FRAMES</a>
<xsl:text>&#32;</xsl:text>
<a href="{$fileOverviewSummary}" class="navigFrameElem" target="_top">NO FRAMES</a>
</ul>
</div>
</div>
<div id="content">
<div class="classSummary">
<h1 id="entityName"><xsl:value-of select="@name" /></h1>
</div>
<p>
<xsl:apply-templates select="ownedComment"/>
</p>
<hr/>
<xsl:if test="count($containerSet) &gt; 0">
<h2>Packages</h2>
<table border="1" class="tableSummary">
<xsl:for-each select="$containerSet">
<tr>
<td>
<xsl:variable name="path">
<xsl:call-template name="getPackageFilePath">
<xsl:with-param name="context" select="."/>
</xsl:call-template>
<xsl:value-of select="@name"/>
</xsl:variable>
<strong><a href="{concat('./', $path, '/', $filePackageSummary)}">
<xsl:call-template name="getPackageNamePart"/>
<xsl:value-of select="@name"/>
</a></strong></td>
<td>
<xsl:call-template name="titleComment"/>
</td>
</tr>
</xsl:for-each>
</table>
</xsl:if>
<!-- added for the non-OO ("global") functions -->
<xsl:variable name="interfaceSet" select="packagedElement[@xmi:type='uml:Interface']" />
<xsl:variable name="classSet" select="packagedElement[@xmi:type='uml:Class']"/>
<xsl:variable name="ownedOperationSet" select="ownedOperation"/>
<xsl:variable name="ownedAttributeSet" select="ownedAttribute"/>
<xsl:variable name="relPathTop"/>
<xsl:if test="count($interfaceSet) &gt; 0">
<h2>Interface summary</h2>
<xsl:call-template name="htmlTableSummary">
<xsl:with-param name="relPathTop" select="$relPathTop"/>
<xsl:with-param name="set" select="$interfaceSet"/>
<xsl:with-param name="filePrefix" select="$fileprefixInterface"/>
</xsl:call-template>
</xsl:if>
<xsl:if test="count($classSet) &gt; 0">
<h2>Class summary</h2>
<xsl:call-template name="htmlTableSummary">
<xsl:with-param name="relPathTop" select="$relPathTop"/>
<xsl:with-param name="set" select="$classSet"/>
<xsl:with-param name="filePrefix" select="$fileprefixClass"/>
</xsl:call-template>
</xsl:if>
<xsl:if test="count($ownedAttributeSet) &gt; 0">
<div id="fieldSummary">
<h2>Field Summary</h2>
<table border="1" class="tableSummary">
<xsl:for-each select="$ownedAttributeSet">
<xsl:call-template name="class-field-summary">
<xsl:with-param name="relPathTop" select="$relPathTop"/>
</xsl:call-template>
</xsl:for-each>
</table>
</div>
</xsl:if>
<xsl:if test="count($ownedOperationSet) &gt; 0">
<div id="methodSummary">
<h2>Method Summary</h2>
<table border="1" class="tableSummary">
<xsl:for-each select="$ownedOperationSet">
<xsl:call-template name="class-method-summary">
<xsl:with-param name="relPathTop" select="$relPathTop"/>
</xsl:call-template>
</xsl:for-each>
</table>
</div>
</xsl:if>
<xsl:if test="count($ownedAttributeSet) &gt; 0">
<div id="fieldDetail">
<h2>Field Detail</h2>
<xsl:for-each select="$ownedAttributeSet">
<xsl:call-template name="class-field-detail">
<xsl:with-param name="relPathTop" select="$relPathTop"/>
</xsl:call-template>
</xsl:for-each>
</div>
</xsl:if>
<xsl:if test="count($ownedOperationSet) &gt; 0">
<div id="methodDetail">
<h2>Method Detail</h2>
<xsl:for-each select="$ownedOperationSet">
<xsl:call-template name="class-method-detail">
<xsl:with-param name="relPathTop" select="$relPathTop"/>
<xsl:with-param name="specifiedBy" select="no"/>
</xsl:call-template>
</xsl:for-each>
</div>
</xsl:if>
</div>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

View File

@@ -0,0 +1,84 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" exclude-result-prefixes="uml xmi"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:uml="http://schema.omg.org/spec/UML/2.1.2"
xmlns:xmi="http://schema.omg.org/spec/XMI/2.1">
<xsl:template name="package-frame">
<xsl:param name="relPathTop"/>
<xsl:param name="classSet"/>
<xsl:param name="interfaceSet"/>
<xsl:param name="ownedOperationSet"/>
<xsl:param name="ownedAttributeSet"/>
<xsl:param name="packageNamePart"/>
<html>
<xsl:call-template name="htmlStartPage"/>
<xsl:call-template name="htmlHead">
<xsl:with-param name="path" select="$relPathTop"/>
<xsl:with-param name="title" select="concat($packageNamePart, @name)"/>
</xsl:call-template>
<body>
<div id="contentFrame">
<h1>
<a href="package-summary.html" target="classFrame">
<xsl:value-of select="concat($packageNamePart, @name)" />
</a>
</h1>
<xsl:if test="count($classSet) &gt; 0">
<h3>Classes</h3>
<ul>
<xsl:for-each select="$classSet">
<xsl:sort select="@name" data-type="text"/>
<li>
<a href="{concat($fileprefixClass, @name,'.html')}" target="classFrame"><xsl:value-of select="@name"/></a>
</li>
</xsl:for-each>
</ul>
</xsl:if>
<xsl:if test="count($interfaceSet) &gt; 0">
<h3>Interfaces</h3>
<ul>
<xsl:for-each select="$interfaceSet">
<xsl:sort select="@name" data-type="text"/>
<li class="interfaceElement">
<a href="{concat($fileprefixInterface, @name, '.html')}" target="classFrame"><xsl:value-of select="@name"/></a>
</li>
</xsl:for-each>
</ul>
</xsl:if>
<xsl:if test="count($ownedOperationSet) &gt; 0">
<h3>Functions</h3>
<ul>
<xsl:for-each select="$ownedOperationSet">
<xsl:sort select="@name" data-type="text"/>
<xsl:variable name="parameters">
<xsl:call-template name="htmlParametersBracket">
<xsl:with-param name="relPathTop" select="$relPathTop"/>
</xsl:call-template>
</xsl:variable>
<li>
<a href="{concat('package-summary.html#', @name, $parameters)}" target="classFrame"><xsl:value-of select="@name"/></a>
</li>
</xsl:for-each>
</ul>
</xsl:if>
<xsl:if test="count($ownedAttributeSet) &gt; 0">
<h3>Constants</h3>
<ul>
<xsl:for-each select="$ownedAttributeSet">
<xsl:sort select="@name" data-type="text"/>
<li>
<a href="{concat('package-summary.html#', @name)}" target="classFrame"><xsl:value-of select="@name"/></a>
</li>
</xsl:for-each>
</ul>
</xsl:if>
</div>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

View File

@@ -0,0 +1,148 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" exclude-result-prefixes="uml xmi exslt exslt-set exslt-functions"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:uml="http://schema.omg.org/spec/UML/2.1.2"
xmlns:xmi="http://schema.omg.org/spec/XMI/2.1"
xmlns:exslt="http://exslt.org/common" xmlns:exslt-set="http://exslt.org/sets"
xmlns:exslt-functions="http://exslt.org/functions">
<xsl:template name="package-summary">
<xsl:param name="relPathTop" />
<xsl:param name="classSet"/>
<xsl:param name="interfaceSet"/>
<xsl:param name="ownedOperationSet" select="$ownedOperationSet"/>
<xsl:param name="ownedAttributeSet" select="$ownedAttributeSet"/>
<xsl:param name="packageNamePart"/>
<xsl:param name="containerName"/>
<xsl:variable name="packageFilePath">
<xsl:call-template name="getPackageFilePath">
<xsl:with-param name="context" select="."></xsl:with-param></xsl:call-template>
</xsl:variable>
<xsl:variable name="previousPreceding" select="(preceding::packagedElement|ancestor::packagedElement)[@xmi:type='uml:Package' or @xmi:type='uml:Model'][last()]"/>
<xsl:variable name="nextFollowing" select="(descendant::packagedElement|following::packagedElement)[@xmi:type='uml:Package' or @xmi:type='uml:Model'][1]"/>
<html>
<xsl:call-template name="htmlStartPage"/>
<xsl:call-template name="htmlHead">
<xsl:with-param name="path" select="$relPathTop"/>
<xsl:with-param name="title" select="concat($packageNamePart, @name)"/>
</xsl:call-template>
<body>
<div id="navigation">
<div id="banner">
<ul class="sections">
<li><a href="{$relPathTop}{$fileOverviewSummary}" title="Summary of all packages">Overview</a></li>
<li class="active">Package</li>
<li>Class</li>
<li><a href="{$relPathTop}{$fileIndexAll}">Index</a></li>
</ul>
<ul class="navigFrame">
<a href="{concat($relPathTop,$fileIndex,'?',$containerName,'/',$packageFilePath,$filePackageSummary)}" class="navigFrameElem" target="_top">FRAMES</a>
<xsl:text>&#32;</xsl:text>
<a href="{$filePackageSummary}" class="navigFrameElem" target="_top">NO FRAMES</a>
</ul>
</div>
<ul class="siblingSections">
<xsl:if test="count($previousPreceding) &gt; 0">
<xsl:variable name="path">
<xsl:call-template name="getPackageFilePath">
<xsl:with-param name="context" select="$previousPreceding/@name"/>
</xsl:call-template>
</xsl:variable>
<li class="last"><a href="{concat($relPathTop, $path, $filePackageSummary)}">Prev Package</a></li>
</xsl:if>
<xsl:if test="count($nextFollowing) &gt; 0">
<xsl:variable name="path">
<xsl:call-template name="getPackageFilePath">
<xsl:with-param name="context" select="$nextFollowing/@name"/>
</xsl:call-template>
</xsl:variable>
<li class="last"><a href="{concat($relPathTop, $path, $filePackageSummary)}">Next Package</a></li>
</xsl:if>
</ul>
</div>
<div id="content">
<div class="classSummary">
<h1 id="entityName">Package <xsl:value-of select="concat($packageNamePart, @name)" /></h1>
</div>
<p>
<xsl:call-template name="htmlDescription">
<xsl:with-param name="baseElement" select="@xmi:id"/>
</xsl:call-template>
</p>
<hr/>
<xsl:if test="count($interfaceSet) &gt; 0">
<h2>Interface summary</h2>
<xsl:call-template name="htmlTableSummary">
<xsl:with-param name="relPathTop" select="$relPathTop"/>
<xsl:with-param name="set" select="$interfaceSet"/>
<xsl:with-param name="filePrefix" select="$fileprefixInterface"/>
</xsl:call-template>
</xsl:if>
<xsl:if test="count($classSet) &gt; 0">
<h2>Class summary</h2>
<xsl:call-template name="htmlTableSummary">
<xsl:with-param name="relPathTop" select="$relPathTop"/>
<xsl:with-param name="set" select="$classSet"/>
<xsl:with-param name="filePrefix" select="$fileprefixClass"/>
</xsl:call-template>
</xsl:if>
<!-- added for the non-OO functions -->
<xsl:if test="count($ownedAttributeSet) &gt; 0">
<div id="fieldSummary">
<h2>Field Summary</h2>
<table border="1" class="tableSummary">
<xsl:for-each select="$ownedAttributeSet">
<xsl:call-template name="class-field-summary">
<xsl:with-param name="relPathTop" select="$relPathTop"/>
</xsl:call-template>
</xsl:for-each>
</table>
</div>
</xsl:if>
<xsl:if test="count($ownedOperationSet) &gt; 0">
<div id="methodSummary">
<h2>Method Summary</h2>
<table border="1" class="tableSummary">
<xsl:for-each select="$ownedOperationSet">
<xsl:call-template name="class-method-summary">
<xsl:with-param name="relPathTop" select="$relPathTop"/>
</xsl:call-template>
</xsl:for-each>
</table>
</div>
</xsl:if>
<xsl:if test="count($ownedAttributeSet) &gt; 0">
<div id="fieldDetail">
<h2>Field Detail</h2>
<xsl:for-each select="$ownedAttributeSet">
<xsl:call-template name="class-field-detail">
<xsl:with-param name="relPathTop" select="$relPathTop"/>
</xsl:call-template>
</xsl:for-each>
</div>
</xsl:if>
<xsl:if test="count($ownedOperationSet) &gt; 0">
<div id="methodDetail">
<h2>Method Detail</h2>
<xsl:for-each select="$ownedOperationSet">
<xsl:call-template name="class-method-detail">
<xsl:with-param name="relPathTop" select="$relPathTop"/>
<xsl:with-param name="specifiedBy" select="no"/>
</xsl:call-template>
</xsl:for-each>
</div>
</xsl:if>
</div>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

Binary file not shown.

After

Width:  |  Height:  |  Size: 65 B

View File

@@ -0,0 +1,236 @@
body {
margin: 0px;
padding: 4px 3px 3px 3px;
}
/**
* Titles
*/
h1 {
font-size: 145%;
}
h1#entityName {
padding:0px 0px 18px 0px;
margin:0px;
}
h2 {
font-size: 145%;
background-color:#CCCCFF;
padding:3px 4px 5px 4px;
margin:15px 0px 4px 0px;
border:1px solid #333;
}
h3 {
font-size: 95%;
}
h3#entityPackage {
margin: 0px;
padding: 0px;
font-size: 90%;
font-family: monospace;
}
.detail h4 {
margin:15px 3px 4px 3px;
}
/**
* Special for the left frames:
*/
div#contentFrame {
padding:6px 0px 0px 3px;
font-family: Arial,Verdana;
font-size: 85%;
}
div#contentFrame h1 {
font-size: 100%;
margin-bottom:2px;
}
div#contentFrame h3 {
font-size: 100%;
margin-bottom:2px;
font-weight:normal;
}
div#contentFrame ul {
list-style: none;
padding:0px 0px 0px 3px;
margin:0px;
}
/**
* Navigation
*/
#navigation {
margin: 0px 3px 3px 3px;
padding: 0px 0px 8px 0px;
border-color: #ccc;
border-width:0px 0px 1px 0px;
border-style:solid;
}
#banner {
margin: 3px 0px;
padding: 0px;
background-color: #EEEEFF;
height: 26px;
}
ul.sections {
list-style: none;
margin: 2px 0px 4px 2px;
padding: 0px;
width: 300px;
overflow: hidden;
float: left;
}
ul.sections li {
display: inline;
margin: 2px 2px 2px 2px;
padding: 0px 2px;
font-size: 100%;
font-weight: normal;
font-family: Arial,Verdana;
color: #000;
line-height:15pt;
}
ul.sections li a {
color:#000;
font-weight: bold;
}
ul.sections li.active {
background-color: #44a;
color: #fff;
font-weight: bold;
}
.siblingSections {
list-style: none;
margin: 0px;
padding: 0px 3px 2px 1px;
overflow: hidden;
clear: both;
}
.siblingSections li {
display: inline;
margin: 0px;
padding: 0px 3px 4px 3px;
font-size: 65%;
text-transform: uppercase;
font-family:Arial,Verdana;
}
.navigFrame {
display: block;
margin: 6px 0px 0px 0px;
padding: 0px;
float: right;
font-size: 65%;
font-family: Arial,Verdana;
}
a.navigFrameElem {
padding-right:15px;
}
/**
* Main
*/
hr {
border-width:0px 0px 1px 0px;
border-color:#ccc;
border-style:solid;
}
code, pre, .code {
font-family: monospace;
font-size: 90%;
}
sup {
font-size: 60%;
}
dl.classTree {
background-color:#f4f4f4;
padding:5px;
margin:0px 0px 10px 0px;
border:1px solid #ccc;
}
dl.classTree dd {
margin: 0px;
padding: 0px;
font-size: 90%;
font-family: monospace;
}
dl.classTree .currentElem {
font-weight:bold;
}
#content {
clear: both;
padding: 16px 0px 0px 5px;
margin: 0px;
}
.tableSummary {
border:1px solid #aaa;
border-collapse:collapse;
font-size:1em;
}
.tableSummary td {
border:1px solid #aaa;
margin:0px;
padding:2px 3px;
font-size:1em;
}
a.linkSummary, a.linkSummary:visited, a.linkSummary:link {
font-weight:bold;
text-decoration:underline;
}
a.linkType, a.linkType:visited, a.linkType:link {
font-weight:normal;
text-decoration:none;
}
a.linkSimple, a.linkSimple:visited, a.linkSimple:link {
font-weight:normal;
text-decoration:underline;
}
.detailContent {
background-color:#f4f4f4;
padding:5px;
margin:0px;
border:1px solid #ccc;
}
h3.titleSmallList {
font-weight: bold;
padding:0px 0px 0px 0px;
margin:0px;
}
div.smallList {
padding:0px 0px 10px 25px;
margin:0px;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 236 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 210 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 287 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 259 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 203 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 230 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 205 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 399 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 399 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 280 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 241 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 179 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 337 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 336 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 338 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 333 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 222 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 203 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 207 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 212 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 191 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 166 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 208 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 212 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 211 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 195 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

@@ -0,0 +1,385 @@
html {
font-size: 62.5%
}
body {
background-color: #fff;
color: #000;
margin: 3px 8px 3px 3px;
padding: 0px;
font: 100% Arial, Verdana, Helvetica, sans-serif;
font-size: 1em;
}
/**
* Right panel
*/
h1 {
font-size:1.8em;
background-repeat:no-repeat;
background-position:top left;
padding:0px 0px 5px 28px;
margin:5px 0px 0px 0px;
width:360px;
border-width:0px 0px 1px 0px;
border-style:solid;
border-color:#ccc;
}
h1.class {
background-image: url(class-big.png);
border-color:#1515ff;
}
h1.datatype {
background-image: url(datatype-big.png);
border-color:#1515ff;
}
h1.interface {
background-image: url(interface-big.png);
border-color:#1515ff;
}
h1.model {
background-image: url(model-big.png);
border-color:#005b00;
}
h1.package {
background-image: url(package-big.png);
border-color:#005b00;
}
h1.index {
background-image: url(index-all-big.png);
margin:5px 0px 20px 0px;
}
h1.help {
background-image: url(help-big.png);
margin:5px 0px 20px 0px;
}
h2 {
border-width:0px 0px 1px 0px;
border-style:solid;
border-color:#ccc;
width:200px;
color:#000;
margin:15px 0px 8px 0px;
font-size:1.4em;
}
ul, li {
font-size:1em;
}
p {
margin:0px;
padding:3px 0px 3px 0px;
}
ul.summary {
list-style-type:none;
margin:0px;
padding-left:20px;
font-size:1.2em;
line-height:1.5em;
}
ul.summary li {
margin:0px;
padding:0px 0px 1px 0px;
}
ul.summary li.Expanded ul {
border:1px solid #ccc;
background-color:#f5f5f5;
padding:0px 3px 4px 22px;
margin:5px 0px 6px 12px;
}
ul.description {
margin:0px 0px 5px 15px;
padding:0px;
list-style-image:url(point.png);
}
ul.description li {
margin:0px;
padding:0px;
}
ul.single {
margin:5px 0px 5px 0px;
padding:0px;
list-style:none;
}
ul.indexAll {
list-style: none;
line-height:17px;
font-size:1.1em;
}
/**
* Navigation bar
*/
ul.navig {
display: inline;
list-style: none;
margin: 0px;
padding: 5px 1px 0px 0px;
float:right;
}
ul.navig li {
display: inline;
margin: 0px;
padding: 0px 0px 0px 6px;
font-size: 1em;
text-transform: uppercase;
color:#333;
}
ul.navig a {
text-decoration:underline;
}
ul.navig a.right {
background: url(right.png) no-repeat center left;
padding-left:11px;
color:#1515ff;
}
ul.navig a.left {
background: url(left.png) no-repeat center left;
padding-left:11px;
color:#1515ff;
}
ul.navig a.top {
background: url(top.png) no-repeat center left;
padding-left:11px;
color:#005b00;
}
ul.navig a.expandAllBtn {
background: url(expand-all.png) no-repeat center left;
padding:0px 8px 0px 16px;
color:#333;
}
ul.navig a.helpBtn {
background: url(help.png) no-repeat center left;
padding:0px 8px 0px 18px;
color:#333;
}
ul.navig a.indexAllBtn {
background: url(index-all.png) no-repeat center left;
padding:0px 8px 0px 19px;
color:#333;
}
#footer {
padding:20px 0px 5px 0px;
font-style:italic;
position:relative;
bottom:0px;
text-align:right;
color:#505050;
}
/**
* Inheritance diagram
*/
dl.inheritTree {
background-color:#f5f5f5;
padding:3px 6px 3px 6px;
margin:5px 0px 5px 0px;
border:1px solid #ccc;
}
dl.inheritTree dd {
margin: 0px;
padding: 0px;
font-size: 1.1em;
}
dl.inheritTree .current {
font-family:"Courier New", monospace;
font-size:1.1em;
font-weight:bold;
}
div.description {
font-size:1.2em;
padding:0px 3px 0px 6px;
margin:20px 0px 10px 0px;
border:1px solid #ccc;
}
div.descriptionPkg {
font-size:1.2em;
padding:0px;
margin:20px 0px 15px 0px;
}
a {
color:#383838;
background-repeat:no-repeat;
background-position:center left;
text-decoration:none;
}
.model {
color:#005b00;
}
.package {
color:#005b00;
}
.class {
color:#1515ff;
}
.datatype {
color:#1515ff;
}
.interface {
color:#1515ff;
}
.property {
color:#bd7a0e;
}
.method {
color:#80233d;
}
/**
* Left menu
*/
#MainList {
padding:0px 0px 0px 3px;
}
#MainList a {
padding:0px 0px 0px 20px;
}
#MainList a.link, span.link {
padding:0px;
color:#1515ff;
font-family:"Courier New", monospace;
font-size:1em;
}
#MainList a.link2 {
padding:0px;
color:#1515ff;
/*text-decoration:underline;*/
font-family:"Courier New", monospace;
font-size:1em;
}
.title {
font-weight:bold;
color:#222;
letter-spacing:1px;
}
.smallTitle {
font-weight:bold;
color:#222;
}
.defVal, .abstract, .note {
font-style:italic;
}
.note {
font-style:italic;
font-size:0.8em;
}
li.smaller {
font-size:0.9em;
}
a.model {
background-image: url(model.png);
font-weight:bold;
}
a.package {
background-image: url(package.png);
}
a.class {
background-image: url(class.png);
}
a.interface {
background-image: url(interface.png);
font-style:italic;
}
a.datatype {
background-image: url(datatype.png);
}
a.property {
background-image: url(property.png);
}
a.property-pub {
background-image: url(property-pub.png);
color:#bd7a0e;
}
a.property-pro {
background-image: url(property-pro.png);
color:#bd7a0e;
}
a.property-pri {
background-image: url(property-pri.png);
color:#bd7a0e;
}
a.method {
background-image: url(method.png);
}
a.method-pub {
background-image: url(method-pub.png);
color:#80233d;
}
a.method-pro {
background-image: url(method-pro.png);
color:#70233d;
}
a.method-pri {
background-image: url(method-pri.png);
color:#70233d;
}
/**
* Treeview
*/
.TreeView {
display:block;
line-height:18px;
font-size:1.2em;
cursor:pointer;
font-style:normal;
}
.TreeView li {
margin:0px;
padding:0 0 0 16px;
list-style:none;
}
.TreeView, .TreeView ul {
margin:0;
padding:0;
}
.TreeView li.Expanded {
background: url(minus.gif) no-repeat left top;
}
li.Expanded ul {
display: block;
}
.TreeView li.Collapsed {
background: url(plus.gif) no-repeat left top;
}
li.Collapsed ul {
display: none;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 178 B

View File

@@ -0,0 +1,165 @@
Array.prototype.indexOf = IndexOf;
//Finds the index of an item in an array
function IndexOf(item) {
for (var i=0; i < this.length; i++) {
if (this[i] == item) {
return i;
}
}
return -1;
}
var toggler = {
//CSS class names
states: Array('Collapsed','Expanded'),
//Caption
statesLib: Array('Collapse', 'Expand'),
//Current state
curState: 1,
//Name of the cookie that stores the current state between pages
cookieName: 'apiTreeviewState',
//Sets all the elements to a new state, and updates the current state variable
toggleAll: function(treeId, btnId)
{
this.curState = 1-this.curState;
this.toggleAllTree(treeId, this.curState)
var btn = document.getElementById(btnId);
btn.innerHTML = this.statesLib[1-this.curState]+' all';
setCookie(this.cookieName, this.curState);
},
//Sets all the elements to a given state
toggleAllTree: function(treeId, stateId)
{
var tree = document.getElementById(treeId);
if(!tree) return;
var treeElements = tree.getElementsByTagName('li');
for (var i=0; i<treeElements.length; i++) {
this.replaceInClass(treeElements[i], this.states[stateId], this.states[1-stateId]);
}
},
//Sets the element to the firstClass given, in place of the second
replaceInClass: function(element, firstClass, secondClass)
{
var classes = element.className.split(" ");
var firstClassIndex = classes.indexOf(firstClass);
var secondClassIndex = classes.indexOf(secondClass);
if (secondClassIndex>-1) {
classes[secondClassIndex] = firstClass;
}
element.className = classes.join(" ");
},
//Toggles between two classes
toggleClass: function(element, firstClass, secondClass, event)
{
event.cancelBubble = true;
var classes = element.className.split(" ");
var firstClassIndex = classes.indexOf(firstClass);
var secondClassIndex = classes.indexOf(secondClass);
if (firstClassIndex == -1 && secondClassIndex == -1) {
classes[classes.length] = firstClass;
}
else if (firstClassIndex != -1) {
classes[firstClassIndex] = secondClass;
}
else {
classes[secondClassIndex] = firstClass;
}
element.className = classes.join(" ");
},
//Toggle event handler for each expandable/collapsable node
toggleNodeStateHandler: function(event)
{
toggler.toggleClass(this, toggler.states[0], toggler.states[1], (event==null) ? window.event : event);
},
//Prevents the onclick event from bubbling up
preventBubbleHandler: function(event)
{
if (!event)
event = window.event;
event.cancelBubble = true;
},
//Adds the relevant onclick handlers for the nodes in the tree view
setupTreeView: function(treeId)
{
var tree = document.getElementById(treeId);
if(!tree) return;
var treeElements = tree.getElementsByTagName("li");
for (var i=0; i<treeElements.length; i++) {
if (treeElements[i].getElementsByTagName("ul").length>0) {
treeElements[i].onclick = toggler.toggleNodeStateHandler;
}
else {
treeElements[i].onclick = toggler.preventBubbleHandler;
}
}
var h = window.location.hash;
if(h!='') {
var s = document.getElementById(h.substring(1));
if(s) {
this.replaceInClass(s, this.states[1], this.states[0]);
}
}
},
backToMemorizedState: function(treeId, btnId)
{
var x = getCookie(this.cookieName);
if (x==0 || x==1) {
this.curState = x;
var btn = document.getElementById(btnId);
btn.innerHTML = this.statesLib[1-this.curState]+' all';
this.toggleAllTree(treeId, this.curState);
}
}
}
function setCookie(name, value, expires, path, domain, secure)
{
var today = new Date();
today.setTime( today.getTime() );
if (expires) {
expires = expires*1000*60*60*24;
}
var expires_date = new Date(today.getTime() + (expires) );
document.cookie = name + "=" +escape(value) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
( ( path ) ? ";path=" + path : "" ) +
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}
function getCookie(check_name)
{
var a_all_cookies = document.cookie.split(';');
var a_temp_cookie = '';
var cookie_name = '';
var cookie_value = '';
var b_cookie_found = false;
for (i=0; i<a_all_cookies.length; i++) {
a_temp_cookie = a_all_cookies[i].split( '=' );
cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');
if (cookie_name == check_name){
b_cookie_found = true;
if (a_temp_cookie.length>1) {
cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
}
return cookie_value;
break;
}
a_temp_cookie = null;
cookie_name = '';
}
if (!b_cookie_found) {
return null;
}
}

View File

@@ -0,0 +1,58 @@
<?php
/**
* PHP_UML
*
* PHP version 5
*
* @category PHP
* @package PHP_UML
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
* @version SVN: $Revision: 169 $
* @link http://pear.php.net/package/PHP_UML
* @since $Date: 2011-09-12 01:28:43 +0200 (lun., 12 sept. 2011) $
*/
/**
* Implementation of the class renderer
*
* @category PHP
* @package PHP_UML
* @subpackage Output
* @subpackage HtmlNew
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
*/
class PHP_UML_Output_HtmlNew_DocClass extends PHP_UML_Output_HtmlNew_DocClassifier
{
protected function getTypeName()
{
return 'class';
}
protected function getStyleName()
{
return 'class';
}
protected function getPrefix()
{
return self::CLASS_PREFIX;
}
protected function getCurrentElement($i)
{
return $this->getContextPackage()->classes[$i];
}
protected function getNextElement($i)
{
return $i+1<count($this->getContextPackage()->classes) ? $this->getContextPackage()->classes[$i+1] : null;
}
protected function getPreviousElement($i)
{
return $i>0 ? $this->getContextPackage()->classes[$i-1] : null;
}
}
?>

View File

@@ -0,0 +1,237 @@
<?php
/**
* PHP_UML
*
* PHP version 5
*
* @category PHP
* @package PHP_UML
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
* @version SVN: $Revision: 169 $
* @link http://pear.php.net/package/PHP_UML
* @since $Date: 2011-09-12 01:28:43 +0200 (lun., 12 sept. 2011) $
*/
/**
* Implementation of the HTML renderer for a classifier (class, interface, datatype)
*
* @category PHP
* @package PHP_UML
* @subpackage Output
* @subpackage HtmlNew
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
*/
abstract class PHP_UML_Output_HtmlNew_DocClassifier extends PHP_UML_Output_HtmlNew_DocElement
{
/**
* Return the type name of the classifier
*
* @return string
*/
abstract protected function getTypeName();
/**
* Return the CSS style name of the classifier
*
* @return string
*/
abstract protected function getStyleName();
/**
* Return the prefix (filename scheme)
*
* @return string
*/
abstract protected function getPrefix();
/**
* Return the current object
*
* @param int $i Current index in all the elements of the package
*
* @return PHP_UML_Metamodel_Classifier
*/
abstract protected function getCurrentElement($i);
/**
* Return the next object
*
* @param int $i Current index in all the elements of the package
*
* @return PHP_UML_Metamodel_Classifier
*/
abstract protected function getNextElement($i);
/**
* Return the previous object
*
* @param int $i Previous index in all the elements of the package
*
* @return PHP_UML_Metamodel_Classifier
*/
abstract protected function getPreviousElement($i);
/**
* Generates and saves the HTML code for a classifier
*
* @param int $i Index of the element (to be found in the Context object)
*/
public function render($i)
{
$p = $this->getCurrentElement($i);
$nav = $this->getNavigationBlock($i);
$tit = $this->getTitleBlock($i);
$this->ignoredTag = array('var'); // we ignore all 'var' docblocks
$str = $this->getDescriptionBlock($p);
$str .= $this->getPropertyBlock($p);
$str .= $this->getFunctionBlock($p);
$str = $this->replaceInTpl($str, $nav, $tit, $p->name);
$this->save($this->getPrefix().$p->name, $str);
}
/**
* Return the HTML code for the navigation bar
*
* @param int $i Index of the current element in the the array containing all
* the elements of the current package
*
* @return string A list of HTML LI
*/
private function getNavigationBlock($i)
{
$prev = $this->getPreviousElement($i);
$next = $this->getNextElement($i);
$type = $this->getTypeName();
$str = $this->getCommonLinks();
if (!empty($prev))
$str .= '<li><a href="'.$this->getPrefix().$prev->name.'.'.self::FILE_EXT.'" class="left">Prev '.$type.'</a></li>';
$str .= $this->getNavigParentPackage();
if (!empty($next))
$str .= '<li><a href="'.$this->getPrefix().$next->name.'.'.self::FILE_EXT.'" class="right">Next '.$type.'</a></li>';
return $str;
}
private function getTitleBlock($i)
{
$elem = $this->getCurrentElement($i);
$str = '<h1 class="'.$this->getStyleName();
if ($elem->isAbstract)
$str .= ' abstract';
return $str.'">'.$elem->name.'</h1>';
}
private function getDescriptionBlock(PHP_UML_Metamodel_Classifier $p)
{
$allInherited = $this->getAllInherited($p);
$nbAllInherited = count($allInherited);
$allImplemented = $this->getAllImplemented($p);
$nbAllImplemented = count($allImplemented);
$allInheriting = $this->getAllInheriting($p);
$nbAllInheriting = count($allInheriting);
$allImplementing = $this->getAllImplementing($p);
$nbAllImplementing = count($allImplementing);
$typeName = $this->getTypeName();
if ($p->isAbstract)
$typeName = 'abstract '.$typeName;
if ($p->isReadOnly)
$typeName = 'final '.$typeName;
$str = '<div class="description"><p>'.ucfirst($typeName).
' <span class="title">'.$this->getQualifiedName($p).'</span>';
$css = 'link2';
if (!empty($p->superClass[0])) {
$str .= ' extends ';
if (is_object($p->superClass[0]))
$str .= $this->getLinkTo($p->superClass[0], $css);
else
$str .= $this->displayUnresolved($p->superClass[0]);
}
if (isset($p->implements)) {
$nbImpl = count($p->implements);
if ($nbImpl>0) {
$str .= ' implements ';
for ($i=0; $i<$nbImpl; $i++) {
if (!empty($p->implements[$i])) {
if (is_object($p->implements[$i]))
$str .= $this->getLinkTo($p->implements[$i], $css);
else
$str .= $this->displayUnresolved($p->implements[$i]);
if ($i<$nbImpl-1)
$str .= ', ';
}
}
}
}
$str .= '</p>';
$str .= '<ul class="description">';
if (!is_null($p->description)) {
$str .= $this->getTagsAsList($p->description);
}
if ($nbAllImplemented>0) {
$str .= '<li>All implemented interfaces: ';
foreach ($allImplemented as $ai) {
$str .= $this->getLinkTo($ai, $css).', ';
}
$str = substr($str, 0, -2);
$str .= '</li>';
}
if ($nbAllInheriting>0) {
$str .= '<li>All subclasses: ';
foreach ($allInheriting as $ai) {
$str .= $this->getLinkTo($ai, $css).', ';
}
$str = substr($str, 0, -2);
$str .= '</li>';
}
if ($nbAllImplementing>0) {
$str .= '<li>All implementing classes: ';
foreach ($allImplementing as $ai) {
$str .= $this->getLinkTo($ai, $css).', ';
}
$str = substr($str, 0, -2);
$str .= '</li>';
}
$str .= $this->getFileInfo($p);
$str .= '</ul></div>';
if ($nbAllInherited>0) {
$str .= '<dl class="inheritTree">';
$sum = -15;
$img = '<img src="'.$this->getContextPackage()->rpt.self::RESOURCES_DIRNAME.'/inherit.gif" alt="extended by "/>';
foreach ($allInherited as $ai) {
$str .= '<dd style="padding-left:'.$sum.'px">';
$fullName = $this->getLinkTo($ai, $css);
if ($sum>0)
$str .= $img;
$sum += 15 + 2*(strlen(strstr($fullName, '>'))-5);
$str .= $fullName.'</dd>';
}
$str .= '<dd style="padding-left:'.$sum.'px" class="current">'.$img;
$str .= $this->getAbsPath($p->package, self::T_NAMESPACE).$p->name.'</dd>';
$str .= '</dl>';
}
return $str;
}
}
?>

View File

@@ -0,0 +1,59 @@
<?php
/**
* PHP_UML
*
* PHP version 5
*
* @category PHP
* @package PHP_UML
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
* @version SVN: $Revision: 169 $
* @link http://pear.php.net/package/PHP_UML
* @since $Date: 2011-09-12 01:28:43 +0200 (lun., 12 sept. 2011) $
*/
/**
* Implementation of the datatype renderer
*
* @category PHP
* @package PHP_UML
* @subpackage Output
* @subpackage HtmlNew
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
*/
class PHP_UML_Output_HtmlNew_DocDatatype extends PHP_UML_Output_HtmlNew_DocClassifier
{
protected function getTypeName()
{
return 'datatype';
}
protected function getStyleName()
{
return 'datatype';
}
protected function getPrefix()
{
return self::DATATYPE_PREFIX;
}
protected function getCurrentElement($i)
{
return $this->getContextPackage()->datatypes[$i];
}
protected function getNextElement($i)
{
return $i+1<count($this->getContextPackage()->datatypes) ? $this->getContextPackage()->datatypes[$i+1] : null;
}
protected function getPreviousElement($i)
{
return $i>0 ? $this->getContextPackage()->datatypes[$i-1] : null;
}
}
?>

View File

@@ -0,0 +1,354 @@
<?php
/**
* PHP_UML
*
* PHP version 5
*
* @category PHP
* @package PHP_UML
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
* @version SVN: $Revision: 176 $
* @link http://pear.php.net/package/PHP_UML
* @since $Date: 2011-09-19 00:03:11 +0200 (lun., 19 sept. 2011) $
*/
/**
* General class for an renderer in the HtmlNew implementation
*
* @category PHP
* @package PHP_UML
* @subpackage Output
* @subpackage HtmlNew
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
*/
abstract class PHP_UML_Output_HtmlNew_DocElement extends PHP_UML_Output_ApiRenderer
{
const FILE_EXT = 'htm';
const RESOURCES_DIRNAME = '$resources';
const HELP_FILENAME = 'help';
const INDEX_FILENAME = 'index';
const INDEXALL_FILENAME = 'index-all';
const MENU_FILENAME = 'menu';
const JS_MAIN_NAME = 'MainList';
const TEMPLATES_DIRNAME = 'templates';
/**
* Constructor
*
* @param PHP_UML_Output_ExporterAPI $exporter Reference to an exporter
*/
public function __construct(PHP_UML_Output_ExporterAPI $exporter)
{
parent::__construct($exporter);
$this->mainTpl = $this->getTemplate('main.htm');
}
protected function getDescription(PHP_UML_Metamodel_Stereotype $s, $annotatedElement='')
{
$tag = PHP_UML_Metamodel_Helper::getStereotypeTag($s, 'description');
if (!is_null($tag))
return nl2br(htmlspecialchars($tag->value));
else
return '';
}
/**
* Renders the operation's parameters, as a comma-sep list, between brackets
*
* @param PHP_UML_Metamodel_Operation $operation The operation
* @param bool $withType If true, adds an hyperlink
*
* @return string
*/
protected function getParameterList(PHP_UML_Metamodel_Operation $operation, $withType = false)
{
$n = count($operation->ownedParameter);
$pieces = array();
for ($i=0; $i<$n; $i++) {
$parameter = $operation->ownedParameter[$i];
if (substr($parameter->direction, 0, 2)=='in') {
$str = '';
if ($withType && isset($parameter->type)) {
if (is_object($parameter->type))
$str .= $this->getLinkTo($parameter->type).' ';
else
$str .= $this->displayUnresolved($parameter->type);
}
if ($parameter->direction=='inout') {
$str .= '&#38;';
}
$str .= $parameter->name;
$str .= $this->getDefaultValue($parameter);
$pieces[] = $str;
}
}
return '('.implode(',', $pieces).')';
}
protected function getDefaultValue(PHP_UML_Metamodel_TypedElement $obj)
{
if ($obj->default!='')
return '<span class="defVal"> = '.htmlentities($obj->default, ENT_QUOTES).'</span>';
else
return '';
}
/**
* Renders a HTML hyperlink towards a given element
* (since datatypes don't own to a "package", we suppose they are located in
* the top package)
*
* @param PHP_UML_Metamodel_Classifier $t The element
* @param string $cssStyle CSS style to use
*
* @return string
*/
protected function getLinkTo(PHP_UML_Metamodel_Classifier $t, $cssStyle='link')
{
$loc = '';
$ns = '';
if (isset($t->package)) {
$loc = $this->getAbsPath($t->package);
$ns = $this->getAbsPath($t->package, self::T_NAMESPACE);
}
return '<a href="'.$this->getContextPackage()->rpt.$loc.self::getObjPrefix($t).$t->name.'.'.
self::FILE_EXT.'" class="'.$cssStyle.'">'.$ns.$t->name.'</a>';
}
/**
* Renders an unresolved type as an HTML span
*
* @param string $type Type, provided as a string
*
* @return string
*/
protected function displayUnresolved($type)
{
return '<span class="link">'.$type.'</span> ';
}
/**
* Renders the properties of a given stereotype as an HTML list (LI tags).
* Docblocks in $ignoredTag are not shown, as well as "return" tag with only a type
*
* @param PHP_UML_Metamodel_Stereotype $s A stereotype
*
* @return string
*/
protected function getTagsAsList(PHP_UML_Metamodel_Stereotype $s)
{
$str = '';
foreach ($s->ownedAttribute as $tag) {
if (!(in_array($tag->name, $this->ignoredTag) || ($tag->name=='return' && strpos($tag->value, ' ')===false))) {
if ($tag->name!='description') {
$str .= '<li class="smaller">';
$str .= '@'.$tag->name.' ';
} else {
$str .= '<li>';
}
if (strlen($tag->value)>0)
$str .= nl2br(htmlspecialchars($tag->value));
$str .= '</li>';
}
}
return $str;
}
/**
* Renders the block "Properties" of a package or a class as HTML
*
* @param PHP_UML_Metamodel_NamedElement $p A classifier/a package
*
* @return string
*/
protected function getPropertyBlock(PHP_UML_Metamodel_NamedElement $p)
{
if (empty($p->ownedAttribute))
return '';
$str = '<h2>Properties</h2>';
$str .= '<ul class="summary">';
foreach ($p->ownedAttribute as $o) {
$str .= '<li class="Collapsed" id="'.$this->generatePropertyId($o).'">';
$str .= '<a href="javascript:void(0);" class="'.
$this->getPropertyStyle($o->visibility).'" target="main">'.
$o->name.'</a>';
$str .= '<ul class="description"><li>';
$str .= ucfirst($o->visibility).' ';
if (!$o->isInstantiable)
$str .= 'static ';
if ($o->isReadOnly)
$str .= 'const ';
if (is_object($o->type))
$str .= $this->getLinkTo($o->type).' ';
else
$str .= $this->displayUnresolved($o->type);
$str .= '<span class="smallTitle">'.$o->name.'</span>'.$this->getDefaultValue($o).'</li>';
if (!is_null($o->description)) {
$str .= $this->getTagsAsList($o->description);
}
$str .= $this->getFileInfo($o);
$str .= '</ul>';
$str .= '</li>';
}
$str .= '</ul>';
return $str;
}
/**
* Renders the block "Function" of a package or a classifier as HTML
*
* @param PHP_UML_Metamodel_NamedElement $p A classifier or a package
*
* @return string
*/
protected function getFunctionBlock(PHP_UML_Metamodel_NamedElement $p)
{
if (empty($p->ownedOperation))
return'';
$str = '<h2>Functions</h2>';
$str .= '<ul class="summary">';
foreach ($p->ownedOperation as $o) {
$fullName = $this->getParameterList($o, true);
$str .= '<li class="Collapsed" id="'.$this->generateFunctionId($o).'">';
$str .= '<a href="javascript:void(0);" class="'.$this->getFunctionStyle($o->visibility);
if ($o->isAbstract)
$str .= ' abstract';
$str .= '" target="main">'.$o->name.'</a>'.$fullName;
$str .= '<ul class="description"><li>';
$str .= ucfirst($o->visibility).' ';
if (!$o->isInstantiable)
$str .= 'static ';
if ($o->isAbstract)
$str .= 'abstract ';
$return = $this->getReturnParam($o);
if (!empty($return)) {
if (is_object($return->type))
$str .= $this->getLinkTo($return->type).' ';
else
$str .= $this->displayUnresolved($return->type);
}
$str .= '<span class="smallTitle">'.$o->name.'</span>'.$fullName.'</li>';
if (!is_null($o->description)) {
$str .= $this->getTagsAsList($o->description);
}
foreach ($this->getAllImplemented($p) as $ai) {
foreach ($ai->ownedOperation as $aiO) {
if ($aiO->name == $o->name && !empty($aiO->description)) {
$txt = $this->getDescription($aiO->description, $aiO->id);
if ($txt!='')
$str .= '<li>'.$txt.'<br/><span class="note">(copied from interface '.$this->getLinkTo($ai).')</span></li>';
}
}
}
foreach ($this->getAllInherited($p) as $ai) {
foreach ($ai->ownedOperation as $aiO) {
if ($aiO->name == $o->name && !empty($aiO->description)) {
$txt = $this->getDescription($aiO->description, $aiO->id);
if ($txt!='')
$str .= '<li>'.$txt.'<br/><span class="note">(copied from class '.$this->getLinkTo($ai).')</span></li>';
}
}
}
$str .= $this->getFileInfo($o);
$str .= '</ul>';
$str .= '</li>';
}
$str .= '</ul>';
return $str;
}
/**
* Returns the HTML for the link "Package" in the navigation bar
*
* @param string $rel A prefix to add to the hyperlink (eg: ../)
*
* @return string
*/
protected function getNavigParentPackage($rel='')
{
return '<li><a href="'.$rel.self::PACKAGE_FILENAME.'.'.self::FILE_EXT.'" class="top">Package</a></li>';
}
/**
* Returns the HTML code for the common items of the navigation bar
*
* @return string
*/
protected function getCommonLinks()
{
return '<li><a href="javascript:toggler.toggleAll(\''.self::JS_MAIN_NAME.'\', \'btnToggle\')" class="expandAllBtn" id="btnToggle">Expand all</a></li>'.
'<li><a href="'.$this->getContextPackage()->rpt.self::HELP_FILENAME.'.'.self::FILE_EXT.'" class="helpBtn">Help</a></li>'.
'<li><a href="'.$this->getContextPackage()->rpt.self::INDEXALL_FILENAME.'.'.self::FILE_EXT.'" class="indexAllBtn">Index</a></li>';
}
/**
* Returns the HTML code for the "File" information tag
*
* @param PHP_UML_Metamodel_NamedElement $p An element
*
* @return string
*/
protected function getFileInfo(PHP_UML_Metamodel_NamedElement $p)
{
if (!empty($p->file->package))
return '<li>File: '.$this->getAbsPath($p->file->package).$p->file->name.'</li>';
else
return '';
}
protected function getPropertyStyle($visibility)
{
return 'property-'.substr($visibility, 0, 3);
}
protected function getFunctionStyle($visibility)
{
return 'method-'.substr($visibility, 0, 3);
}
/**
* Replace the template's placeholders with their value
*
* @param string $main Main HTML content (generated by PHP_UML)
* @param string $nav Navigation HTML content (navig bar)
* @param string $tit Title content
* @param string $name Element name
*
* @return string
*/
protected function replaceInTpl($main, $nav, $tit, $name)
{
$str = str_replace('#NAVIG', $nav, $this->mainTpl);
$str = str_replace('#TITLE', $tit, $str);
$str = str_replace('#DETAIL', $main, $str);
$str = str_replace('#RELPATHTOP', $this->getContextPackage()->rpt, $str);
$str = str_replace('#NAME', $this->getTypeName().' '.$name, $str);
$str = str_replace('#CURDATE', date("M j, Y, G:i:s O"), $str);
return $str;
}
protected function getTemplateDirectory()
{
return dirname(__FILE__).DIRECTORY_SEPARATOR.self::TEMPLATES_DIRNAME;
}
protected function save($elementName, $str)
{
$fic = $this->getContextPackage()->dir.$elementName.'.'.self::FILE_EXT;
file_put_contents($fic, $str);
}
}
?>

View File

@@ -0,0 +1,159 @@
<?php
/**
* PHP_UML
*
* PHP version 5
*
* @category PHP
* @package PHP_UML
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
* @version SVN: $Revision: 176 $
* @link http://pear.php.net/package/PHP_UML
* @since $Date: 2011-09-19 00:03:11 +0200 (lun., 19 sept. 2011) $
*/
/**
* Implementation of the HTML renderer for the Index page
*
* @category PHP
* @package PHP_UML
* @subpackage Output
* @subpackage HtmlNew
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
*/
class PHP_UML_Output_HtmlNew_DocIndex extends PHP_UML_Output_HtmlNew_DocMenu
{
/**
* Temporary structure to store all the elements (in order to sort them)
* @var array First index: the element, Second index: filepath to detail page, Third index: true only for operations/attributes of a Package (procedural code)
*/
private $elements = array();
/**
* Generates and saves the HTML code for the Index page
*
* @param PHP_UML_Metamodel_Package $p Package to render
*/
public function render($p)
{
$tpl = $this->getTemplate(self::INDEXALL_FILENAME.'.'.self::FILE_EXT);
$nav = $this->getNavigationBlock();
$str = '<ul id="MainList" class="indexAll">';
$str .= $this->getContent($p);
$str .= '</ul>';
$tmp = str_replace('#NAVIG', $nav, $tpl);
$str = str_replace('#INDEX', $str, $tmp);
$this->save(self::INDEXALL_FILENAME, $str);
}
/**
* Return the HTML code for an Index page
*
* @param PHP_UML_Metamodel_Package $p Starting package
*
* @return string HTML code
*/
private function getContent(PHP_UML_Metamodel_Package $p)
{
$this->readPackage($p);
$str = '';
usort($this->elements, array('self', 'compareElt'));
foreach ($this->elements as $x) {
list($elt, $path, $pkgElt) = $x;
switch(get_class($elt)) {
case self::META_CLASS:
case self::META_INTERFACE:
$str .= $this->getClassifierItem($elt, $path, 0);
break;
case self::META_OPERATION:
if ($pkgElt)
$str .= $this->getPackageOperationItem($elt, $path);
else
$str .= $this->getOperationItem($elt, $path);
break;
case self::META_PROPERTY:
if ($pkgElt)
$str .= $this->getPackagePropertyItem($elt, $path);
else
$str .= $this->getPropertyItem($elt, $path);
break;
}
}
return $str;
}
static private function compareElt($a, $b)
{
return strcasecmp($a[0]->name, $b[0]->name);
}
/**
* Set the elements[] property with the API data of a package
*
* @param PHP_UML_Metamodel_Package $p Package
* @param string $path Relative path to the current package
* @param string $level Recursion level
*
* @return void
*/
private function readPackage(PHP_UML_Metamodel_Package $p, $path='', $level=0)
{
foreach ($p->nestedPackage as $np) {
$npDir = $path.$np->name;
$this->readPackage($np, $npDir.'/', $level+1);
}
foreach ($p->ownedType as $c) {
$this->elements[] = array($c, $path, false);
foreach ($c->ownedOperation as $o) {
$this->elements[] = array($o, $path, false);
}
if (isset($c->ownedAttribute)) {
foreach ($c->ownedAttribute as $a) {
$this->elements[] = array($a, $path, false);
}
}
}
foreach ($p->ownedOperation as $o) {
$this->elements[] = array($o, $path, true);
}
foreach ($p->ownedAttribute as $a) {
$this->elements[] = array($a, $path, true);
}
}
/**
* Return the HTML code for the navigation bar
*
* @return string
*/
private function getNavigationBlock()
{
$str = '<ul class="navig">';
$str .= $this->getCommonLinks();
$str .= '</ul>';
return $str;
}
protected function getPropertyItem(PHP_UML_Metamodel_Property $p, $path)
{
return '<li>'.
'<a href="'.$path.self::getObjPrefix($p->class).$p->class->name.'.'.self::FILE_EXT.'#'.$p->name.
'" class="'.$this->getPropertyStyle($p->visibility).'" target="main">'.$p->name.'</a>'.
'</li>';
}
protected function getOperationItem(PHP_UML_Metamodel_Operation $o, $path)
{
return '<li>'.
'<a href="'.$path.self::getObjPrefix($o->class).$o->class->name.'.'.self::FILE_EXT.'#f'.$o->id.
'" class="'.$this->getFunctionStyle($o->visibility).'" target="main">'.$o->name.$this->getParameterList($o).'</a>'.
'</li>';
}
}
?>

View File

@@ -0,0 +1,59 @@
<?php
/**
* PHP_UML
*
* PHP version 5
*
* @category PHP
* @package PHP_UML
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
* @version SVN: $Revision: 169 $
* @link http://pear.php.net/package/PHP_UML
* @since $Date: 2011-09-12 01:28:43 +0200 (lun., 12 sept. 2011) $
*/
/**
* Implementation of the class renderer
*
* @category PHP
* @package PHP_UML
* @subpackage Output
* @subpackage HtmlNew
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
*/
class PHP_UML_Output_HtmlNew_DocInterface extends PHP_UML_Output_HtmlNew_DocClassifier
{
protected function getTypeName()
{
return 'interface';
}
protected function getStyleName()
{
return 'interface';
}
protected function getPrefix()
{
return self::INTERFACE_PREFIX;
}
protected function getCurrentElement($i)
{
return $this->getContextPackage()->interfaces[$i];
}
protected function getNextElement($i)
{
return $i+1<count($this->getContextPackage()->interfaces) ? $this->getContextPackage()->interfaces[$i+1] : null;
}
protected function getPreviousElement($i)
{
return $i>0 ? $this->getContextPackage()->interfaces[$i-1] : null;
}
}
?>

View File

@@ -0,0 +1,126 @@
<?php
/**
* PHP_UML
*
* PHP version 5
*
* @category PHP
* @package PHP_UML
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
* @version SVN: $Revision: 176 $
* @link http://pear.php.net/package/PHP_UML
* @since $Date: 2011-09-19 00:03:11 +0200 (lun., 19 sept. 2011) $
*/
/**
* Implementation of the HTML renderer for the treeview menu (on the left panel)
*
* @category PHP
* @package PHP_UML
* @subpackage Output
* @subpackage HtmlNew
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
*/
class PHP_UML_Output_HtmlNew_DocMenu extends PHP_UML_Output_HtmlNew_DocElement
{
/**
* Generates and saves the HTML menu
*
* @param PHP_UML_Metamodel_Package $p Starting package
*/
public function render($p)
{
$tpl = $this->getTemplate(self::MENU_FILENAME.'.'.self::FILE_EXT);
$str = '<ul class="TreeView" id="MainList">';
$str .= $this->getContent($p);
$str .= '</ul>';
$str = str_replace('#MENU', $str, $tpl);
$this->save(self::MENU_FILENAME, $str);
}
/**
* Returns the HTML content for a whole model
*
* @param PHP_UML_Metamodel_Package $p Starting package
*
* @return string
*/
private function getContent(PHP_UML_Metamodel_Package $p)
{
return $this->getPackage($p);
}
/**
* Returns the HTML content for a given package
*
* @param PHP_UML_Metamodel_Package $p Package
* @param string $path Relative path to the current package
* @param int $level Recursion level
*
* @return string
*/
private function getPackage(PHP_UML_Metamodel_Package $p, $path='', $level=0)
{
$pt = $level>0 ? 'package' : 'model';
$empty = (count($p->nestedPackage)==0 && count($p->ownedType)==0 && count($p->ownedOperation)==0 && count($p->ownedAttribute)==0);
$str = ($level==0 ? '<li class="Expanded">' : ($empty ? '<li>' : '<li class="Collapsed">'));
$str .= '<a href="'.$path.self::PACKAGE_FILENAME.'.'.self::FILE_EXT.'" class="'.$pt.'" target="main">'.$p->name.'</a>';
if (!$empty) {
$str .= '<ul>';
foreach ($p->nestedPackage as $np) {
$npDir = $path.$np->name;
$str .= $this->getPackage($np, $npDir.'/', $level+1);
}
foreach ($p->ownedType as $c) {
$str .= $this->getClassifierItem($c, $path, $level);
}
foreach ($p->ownedAttribute as $a) {
$str .= $this->getPackagePropertyItem($a, $path);
}
foreach ($p->ownedOperation as $o) {
$str .= $this->getPackageOperationItem($o, $path);
}
$str .= '</ul>';
}
$str .= '</li>';
return $str;
}
protected function getPackagePropertyItem(PHP_UML_Metamodel_Property $p, $path)
{
return '<li>'.
'<a href="'.$path.self::PACKAGE_FILENAME.'.'.self::FILE_EXT.'#'.$this->generatePropertyId($p).
'" class="property" target="main">'.$p->name.'</a>'.
'</li>';
}
protected function getPackageOperationItem(PHP_UML_Metamodel_Operation $o, $path)
{
return '<li>'.
'<a href="'.$path.self::PACKAGE_FILENAME.'.'.self::FILE_EXT.'#'.$this->generateFunctionId($o).
'" class="method" target="main">'.$o->name.$this->getParameterList($o).'</a>'.
'</li>';
}
protected function getClassifierItem(PHP_UML_Metamodel_Classifier $c, $path, $level)
{
$str = '';
if ($level>0 || !in_array($c->name, $this->hiddenClassifiers)) {
$str .= '<li>'.
'<a href="'.$path.self::getObjPrefix($c).$c->name.'.'.self::FILE_EXT.
'" class="'.self::getObjStyle($c);
if ($c->isAbstract)
$str .= ' abstract';
$str .= '" target="main">'.$c->name.'</a></li>';
}
return $str;
}
}
?>

View File

@@ -0,0 +1,144 @@
<?php
/**
* PHP_UML
*
* PHP version 5
*
* @category PHP
* @package PHP_UML
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
* @version SVN: $Revision: 169 $
* @link http://pear.php.net/package/PHP_UML
* @since $Date: 2011-09-12 01:28:43 +0200 (lun., 12 sept. 2011) $
*/
/**
* Implementation of the HTML renderer for a Package
*
* @category PHP
* @package PHP_UML
* @subpackage Output
* @subpackage HtmlNew
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
*/
class PHP_UML_Output_HtmlNew_DocPackage extends PHP_UML_Output_HtmlNew_DocElement
{
/**
* Generates and saves the HTML code for a package
*
* @param PHP_UML_Metamodel_Package $p Starting package
*/
public function render($p)
{
if ($this->getContextPackage()->dir=='') {
$fullName = $p->name;
} else {
$fullName = rtrim($this->getAbsPath($p, self::T_NAMESPACE), self::T_NAMESPACE);
}
$nav = $this->getNavigationBlock();
$tit = $this->getTitleBlock($fullName);
$str = $this->getDescriptionBlock($p);
$str .= $this->getPropertyBlock($p);
$str .= $this->getFunctionBlock($p);
$str = $this->replaceInTpl($str, $nav, $tit, $fullName);
$this->save(self::PACKAGE_FILENAME, $str);
}
private function getDescriptionBlock($p)
{
$str = '';
if (!is_null($p->description)) {
$str .= '<div class="descriptionPkg"><p><ul class="single">'.$this->getTagsAsList($p->description).'</ul></p></div>';
}
if (count($p->nestedPackage)>0) {
$str .= '<h2>Packages</h2>';
$str .= '<ul class="summary">';
foreach ($p->nestedPackage as $np) {
$str .= '<li>';
$str .= '<a href="'.$np->name.'/'.self::PACKAGE_FILENAME.'.'.self::FILE_EXT.'" class="package" target="main">'.$np->name.'</a>';
$str .= '</li>';
}
$str .= '</ul>';
}
$display = false;
$tmp = '<h2>Classes</h2>';
$tmp .= '<ul class="summary">';
foreach ($this->getContextPackage()->classes as $o) {
if ($this->getContextPackage()->dir!='' || !in_array($o->name, $this->hiddenClasses)) {
$display = true;
$tmp .= '<li>'.
'<a href="'.self::getObjPrefix($o).$o->name.'.'.self::FILE_EXT.'" class="'.self::getObjStyle($o).'" target="main">'.$o->name.'</a>'.
'</li>';
}
}
$tmp .= '</ul>';
if ($display)
$str .= $tmp;
$display = false;
$tmp = '<h2>Interfaces</h2>';
$tmp .= '<ul class="summary">';
foreach ($this->getContextPackage()->interfaces as $o) {
if ($this->getContextPackage()->dir!='' || !in_array($o->name, $this->hiddenInterfaces)) {
$display = true;
$tmp .= '<li>'.
'<a href="'.self::getObjPrefix($o).$o->name.'.'.self::FILE_EXT.'" class="'.self::getObjStyle($o).'" target="main">'.$o->name.'</a>'.
'</li>';
}
}
$tmp .= '</ul>';
if ($display)
$str .= $tmp;
return $str;
}
/**
* Return the HTML code for the navigation bar
*
* @return string
*/
private function getNavigationBlock()
{
$str = $this->getCommonLinks();
if (!empty($this->getContextPackage()->rpt))
$str .= $this->getNavigParentPackage('../');
return $str;
}
private function getTitleBlock($name)
{
return '<h1 class="'.$this->getStyleName().'">'.$name.'</h1>';
}
private function getStyleName()
{
return $this->getContextPackage()->dir=='' ? 'model' : 'package';
}
protected function getTypeName()
{
return $this->getStyleName();
}
protected function getPropertyStyle($visibility)
{
return 'property';
}
protected function getFunctionStyle($visibility)
{
return 'method';
}
}
?>

View File

@@ -0,0 +1,55 @@
<?php
/**
* PHP_UML
*
* PHP version 5
*
* @category PHP
* @package PHP_UML
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
* @version SVN: $Revision: 169 $
* @link http://pear.php.net/package/PHP_UML
* @since $Date: 2011-09-12 01:28:43 +0200 (lun., 12 sept. 2011) $
*/
/**
* Rendering of the resources
*
* @category PHP
* @package PHP_UML
* @subpackage Output
* @subpackage HtmlNew
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
*/
class PHP_UML_Output_HtmlNew_DocResources extends PHP_UML_Output_HtmlNew_DocElement
{
public function render($p)
{
$dir = $this->getContextPackage()->dir;
$baseSrc = dirname(__FILE__).DIRECTORY_SEPARATOR;
$index = $this->getTemplate(self::INDEX_FILENAME.'.'.self::FILE_EXT);
$modelName = $p->name;
$index = str_replace('#MODELNAME', $modelName, $index);
file_put_contents($dir.self::INDEX_FILENAME.'.'.self::FILE_EXT, $index);
$src = dirname(__FILE__).DIRECTORY_SEPARATOR.self::TEMPLATES_DIRNAME.DIRECTORY_SEPARATOR.self::HELP_FILENAME.'.'.self::FILE_EXT;
copy($src, $dir.self::HELP_FILENAME.'.'.self::FILE_EXT);
$src = $baseSrc.self::RESOURCES_DIRNAME;
$dest = $dir.self::RESOURCES_DIRNAME;
if (!file_exists($dest)) {
mkdir($dest);
}
if (file_exists($src)) {
$iterator = new DirectoryIterator($src);
foreach ($iterator as $file) {
if ($file->isFile())
copy($file->getPathname(), $dest.DIRECTORY_SEPARATOR.$file->getFilename());
}
}
}
}
?>

View File

@@ -0,0 +1,102 @@
<?php
/**
* PHP_UML
*
* PHP version 5
*
* @category PHP
* @package PHP_UML
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
* @version SVN: $Revision: 176 $
* @link http://pear.php.net/package/PHP_UML
* @since $Date: 2011-09-19 00:03:11 +0200 (lun., 19 sept. 2011) $
*/
/**
* This class generates an HTML website from a UML model (a PHP_UML_Metamodel)
*
* @category PHP
* @package PHP_UML
* @subpackage Output
* @subpackage HtmlNew
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
*/
class PHP_UML_Output_HtmlNew_Exporter extends PHP_UML_Output_ExporterAPI
{
private $docClass;
private $docInterface;
private $docDatatype;
private $docPackage;
private $docMenu;
private $docIndex;
private $docResources;
public function export($outDir)
{
$userCurrentDir = getcwd();
if (substr($outDir, -1) != DIRECTORY_SEPARATOR)
$outDir .= DIRECTORY_SEPARATOR;
parent::export($outDir);
$this->ctx = new PHP_UML_Output_ApiContextPackage();
$this->docClass = new PHP_UML_Output_HtmlNew_DocClass($this);
$this->docInterface = new PHP_UML_Output_HtmlNew_DocInterface($this);
$this->docDatatype = new PHP_UML_Output_HtmlNew_DocDatatype($this);
$this->docPackage = new PHP_UML_Output_HtmlNew_DocPackage($this);
$this->docMenu = new PHP_UML_Output_HtmlNew_DocMenu($this);
$this->docIndex = new PHP_UML_Output_HtmlNew_DocIndex($this);
$this->docResources = new PHP_UML_Output_HtmlNew_DocResources($this);
chdir($outDir);
$this->docResources->render($this->structure->packages);
$this->docMenu->render($this->structure->packages);
$this->docIndex->render($this->structure->packages);
// we analyse the inheritance/impl relations beforehand:
$this->setAllSuperClassifiers($this->structure->packages);
$this->treatPackage($this->structure->packages);
chdir($userCurrentDir);
}
/**
* Recurses into the packages, and generates the detailed file (one file
* per class/interface/package)
*
* @param PHP_UML_Metamodel_Package $pkg Starting package
* @param string $dir Filepath leading to the current package
* @param string $rpt Relative filepath to the top package
*/
private function treatPackage(PHP_UML_Metamodel_Package $pkg, $dir='', $rpt='')
{
$this->initContextPackage($pkg, $dir, $rpt);
$this->docPackage->render($pkg, $this->ctx);
$nbc = count($this->ctx->classes);
$nbi = count($this->ctx->interfaces);
$nbd = count($this->ctx->datatypes);
for ($i=0; $i<$nbc; $i++)
$this->docClass->render($i);
for ($i=0; $i<$nbi; $i++)
$this->docInterface->render($i);
for ($i=0; $i<$nbd; $i++)
$this->docDatatype->render($i);
foreach ($pkg->nestedPackage as $np) {
$npDir = $dir.$np->name;
if (!file_exists($npDir))
mkdir($npDir);
$this->treatPackage($np, $npDir.DIRECTORY_SEPARATOR, '../'.$rpt);
}
}
}
?>

View File

@@ -0,0 +1,67 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1"/>
<title>API Help</title>
<link type="text/css" rel="stylesheet" href="$resources/style.css"/>
<script type="text/javascript" language="javascript" src="$resources/treeview.js"></script>
</head>
<body>
<h1 class="help">How this API document is organized</h1>
<div class="description">
<h2>Menu</h2>
<p>The menu in the left panel provides a treeview of all packages, classes and interfaces.
It also contains the procedural functions and global constants (defined with the <i>define</i> keyword).
Click on a item to display its detailed page in the right panel.</p>
<h2>Package</h2>
<p>Each package has a page that contains a list of its classes, interfaces, with a summary for each.</p>
<p>Even if packages don't exist by themselves in PHP, PHP_UML reconstitutes them using the PHP namespaces (from PHP 5.3),
or by using the docblock @package (if the source code has some).<br/>
The top package is showed like a UML Model, and matches the "global namespace" of PHP.</p>
<p>From version 1.5, PHP_UML can display non strictly object-oriented elements, like procedural functions and global
constants. The former appear under "Functions" and the latter under "Properties", inside the Package page that matches the
namespace that these elements belong to.</p>
<h2>Class/Interface</h2>
<p>Each class and interface has its own separate page. Each of these pages starts with a description block.</p>
<p>The description block displays the content of the comment just preceding the class/interface definition in the source code,
followed by a list of the docblocks, as well the source file name.<br/>
It also lists : all inherited classes, all subclasses, all known subinterfaces, and all known implementing classes.</p>
<p>Then the following elements appear:</p>
<ul>
<li>Class inheritance diagram</li>
<li>Function Summary (all the methods of the class/interface)</li>
<li>Property Summary (all the constants and properties of the class)</li>
</ul>
<p>Click on a function/property title to expand it down, and see more detailed information about it (comment, docblocks).</p>
<p>All elements are in the order they appear in the source code.</p>
<h2>Index</h2>
<p>The Index contains an alphabetic list of all classes, interfaces, functions, properties and constants.</p>
<h2>Prev/Next</h2>
<p>These links take you to the next or previous class, interface, package, or related page.</p>
<h2>Expand/Collapse all</h2>
<p>In a class/interface/package page, click on "Expand all" to expand the detailed information about all members (functions, properties...).
The state of the button "Expand all / Collapse all" is preserved between page requests (unless you have cookies disabled in your browser).</p>
<h2>PHP and types</h2>
<p>Even though PHP is not a strong typed language, PHP_UML relies on a set of predefined types (integer, float, string, mixed, etc.)
and tries to use them as much as it can guess. When it had not been able to resolve a type/class/interface
(for example, a class implements an interface whose source code had not been provided), the type is displayed, but is not clickable.</p>
<p>PHP_UML is also aware of a couple of internal PHP classifiers, such as Exception or Iterator.</p>
</div>
</body>
</html>

View File

@@ -0,0 +1,14 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1"/>
<title>#MODELNAME</title>
<link type="text/css" rel="stylesheet" href="$resources/style.css"/>
<script type="text/javascript" language="javascript" src="$resources/treeview.js"></script>
</head>
<body onload="toggler.setupTreeView('TreeView');">
#NAVIG
<h1 class="index">Index</h1>
#INDEX
</body>
</html>

View File

@@ -0,0 +1,11 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1"/>
<title>#MODELNAME API documentation</title>
</head>
<frameset cols="20%,80%">
<frame name="menu" src="menu.htm" frameborder="0"/>
<frame name="main" src="package-summary.htm" frameborder="0"/>
</frameset>
</html>

View File

@@ -0,0 +1,19 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1"/>
<title>#NAME</title>
<link type="text/css" rel="stylesheet" href="#RELPATHTOP$resources/style.css"/>
<script type="text/javascript" language="javascript" src="#RELPATHTOP$resources/treeview.js"></script>
</head>
<body onload="toggler.setupTreeView('MainList');toggler.backToMemorizedState('MainList', 'btnToggle')">
<ul class="navig">
#NAVIG
</ul>
#TITLE
<div id="MainList">
#DETAIL
</div>
<div id="footer">Documentation generated on #CURDATE by <a href="http://pear.php.net/package/PHP_UML/" target="_new">PHP_UML</a></div>
</body>
</html>

View File

@@ -0,0 +1,14 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1"/>
<title>API Menu</title>
<link type="text/css" rel="stylesheet" href="$resources/style.css"/>
<script type="text/javascript" language="javascript" src="$resources/treeview.js"></script>
</head>
<body onload="toggler.setupTreeView('MainList');">
#MENU
</body>
</html>

View File

@@ -0,0 +1,58 @@
<?php
/**
* PHP_UML
*
* PHP version 5
*
* @category PHP
* @package PHP_UML
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
* @version SVN: $Revision: 136 $
* @link http://pear.php.net/package/PHP_UML
* @since $Date: 2009-12-10 01:35:58 +0100 (jeu., 10 déc. 2009) $
*/
/**
* Implementation of the class renderer
*
* @category PHP
* @package PHP_UML
* @subpackage Output
* @subpackage Php
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
*/
class PHP_UML_Output_Php_DocClass extends PHP_UML_Output_Php_DocClassifier
{
protected function getTypeName()
{
return 'class';
}
protected function getStyleName()
{
return 'class';
}
protected function getPrefix()
{
return self::CLASS_PREFIX;
}
protected function getCurrentElement($i)
{
return $this->getContextPackage()->classes[$i];
}
protected function getNextElement($i)
{
return $i+1<count($this->getContextPackage()->classes) ? $this->getContextPackage()->classes[$i+1] : null;
}
protected function getPreviousElement($i)
{
return $i>0 ? $this->getContextPackage()->classes[$i-1] : null;
}
}
?>

View File

@@ -0,0 +1,168 @@
<?php
/**
* PHP_UML
*
* PHP version 5
*
* @category PHP
* @package PHP_UML
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
* @version SVN: $Revision: 139 $
* @link http://pear.php.net/package/PHP_UML
* @since $Date: 2009-12-13 21:48:54 +0100 (dim., 13 déc. 2009) $
*/
/**
* Implementation of the HTML renderer for a classifier (class, interface, datatype)
*
* @category PHP
* @package PHP_UML
* @subpackage Output
* @subpackage Php
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
*/
abstract class PHP_UML_Output_Php_DocClassifier extends PHP_UML_Output_Php_DocElement
{
/**
* Return the type name of the classifier
*
* @return string
*/
abstract protected function getTypeName();
/**
* Return the CSS style name of the classifier
*
* @return string
*/
abstract protected function getStyleName();
/**
* Return the prefix (filename scheme)
*
* @return string
*/
abstract protected function getPrefix();
/**
* Return the current object
*
* @param int $i Current index in all the elements of the package
*
* @return PHP_UML_Metamodel_Classifier
*/
abstract protected function getCurrentElement($i);
/**
* Return the next object
*
* @param int $i Current index in all the elements of the package
*
* @return PHP_UML_Metamodel_Classifier
*/
abstract protected function getNextElement($i);
/**
* Return the previous object
*
* @param int $i Previous index in all the elements of the package
*
* @return PHP_UML_Metamodel_Classifier
*/
abstract protected function getPreviousElement($i);
/**
* Generates and saves the HTML code for a classifier
*
* @param int $i Index of the element (to be found in the Context object)
*/
public function render($i)
{
$p = $this->getCurrentElement($i);
$nsDeclaration = '';
$ns = '';
if (isset($p->package)) {
$ns = substr($this->getAbsPath($p->package, self::T_NAMESPACE), 0, -1);
if (!empty($ns))
$nsDeclaration = 'namespace '.$ns.';'.$this->getNl();
}
$header = $this->exporter->getDocblocks() ? '/**'.$this->getNl().
' * @author '.PHP_UML_Output_Exporter::APP_NAME.$this->getNl().
' * @since '.date("M j, Y, G:i:s O").$this->getNl().
(empty($ns) ? '' : ' * @package '.$ns.$this->getNl()).
' */' : '';
$str = $this->getMainBlock($p);
$str .= $this->getNl().'{'.$this->getNl();
$str .= $this->getPropertyBlock($p);
$str .= $this->getNl();
$str .= $this->getFunctionBlock($p);
$str .= '}';
$str = $this->replaceInTpl($str, $header, $nsDeclaration, $p->name);
$this->save($p->name, $str);
}
private function getMainBlock(PHP_UML_Metamodel_Classifier $p)
{
$allInherited = $this->getAllInherited($p);
$nbAllInherited = count($allInherited);
$allImplemented = $this->getAllImplemented($p);
$nbAllImplemented = count($allImplemented);
$allInheriting = $this->getAllInheriting($p);
$nbAllInheriting = count($allInheriting);
$allImplementing = $this->getAllImplementing($p);
$nbAllImplementing = count($allImplementing);
$typeName = $this->getTypeName();
if ($p instanceof PHP_UML_Metamodel_Class) {
if ($p->isAbstract)
$typeName = 'abstract '.$typeName;
if ($p->isReadOnly)
$typeName = 'final '.$typeName;
}
$str = '';
if (!is_null($p->description)) {
$str .= $this->getTagsAsList($p->description);
}
$str .= $typeName.' '.$p->name.' ';
if (!empty($p->superClass[0])) {
$str .= 'extends ';
if (is_object($p->superClass[0]))
$str .= $this->getLinkTo($p->superClass[0]);
else
$str .= $this->displayUnresolved($p->superClass[0]);
$str .= ' ';
}
if (isset($p->implements)) {
$nbImpl = count($p->implements);
if ($nbImpl>0) {
$str .= 'implements ';
for ($i=0; $i<$nbImpl; $i++) {
if (!empty($p->implements[$i])) {
if (is_object($p->implements[$i]))
$str .= $this->getLinkTo($p->implements[$i]);
else
$str .= $this->displayUnresolved($p->implements[$i]);
if ($i<$nbImpl-1)
$str .= ', ';
}
}
}
}
return $str;
}
}
?>

View File

@@ -0,0 +1,361 @@
<?php
/**
* PHP_UML
*
* PHP version 5
*
* @category PHP
* @package PHP_UML
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
* @version SVN: $Revision$
* @link http://pear.php.net/package/PHP_UML
* @since $Date$
*/
/**
* General class for an renderer in the PHP implementation
*
* @category PHP
* @package PHP_UML
* @subpackage Output
* @subpackage Php
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
*/
abstract class PHP_UML_Output_Php_DocElement extends PHP_UML_Output_ApiRenderer
{
const FILE_EXT = 'php';
const TEMPLATES_DIRNAME = 'templates';
/**
* Constructor
*
* @param PHP_UML_Output_ExporterAPI $exporter Reference to an exporter
*/
public function __construct(PHP_UML_Output_ExporterAPI $exporter)
{
parent::__construct($exporter);
$this->mainTpl = $this->getTemplate('main.php');
}
protected function getDescription(PHP_UML_Metamodel_Stereotype $s, $annotatedElement='')
{
$tag = PHP_UML_Metamodel_Helper::getStereotypeTag($s, 'description');
if (!is_null($tag))
return $tag->value;
else
return '';
}
/**
* Renders the operation's parameters, as a comma-sep list, between brackets
*
* @param PHP_UML_Metamodel_Operation $operation The operation
* @param bool $withType If true, adds an hyperlink
*
* @return string
*/
protected function getParameterList(PHP_UML_Metamodel_Operation $operation, $withType = false)
{
$str = '(';
$n = count($operation->ownedParameter);
for ($i=0; $i<$n; $i++) {
$parameter = $operation->ownedParameter[$i];
if (substr($parameter->direction, 0, 2)=='in') {
if ($withType && isset($parameter->type) && !($parameter->type instanceof PHP_UML_Metamodel_Datatype)) {
if (is_object($parameter->type))
$str .= $this->getLinkTo($parameter->type).' ';
else if (strcasecmp($parameter->type, 'array')==0)
$str .= $this->displayUnresolved($parameter->type).' ';
}
if ($parameter->direction=='inout') {
$str .= '&';
}
if ($parameter->name[0] != '$')
$str .= '$';
$str .= $parameter->name;
$str .= $this->getDefaultValue($parameter);
if ($i<($n-1))
$str .= ', ';
}
}
$str .= ')';
return $str;
}
protected function getDefaultValue(PHP_UML_Metamodel_TypedElement $obj)
{
if ($obj->default!='')
return '='.$obj->default;
else
return '';
}
/**
* Renders a link towards a given element
* (since datatypes don't own to a "package", we suppose they are located in
* the top package)
*
* @param PHP_UML_Metamodel_Classifier $t The element
* @param string $cssStyle CSS style to use
*
* @return string
*/
protected function getLinkTo(PHP_UML_Metamodel_Classifier $t, $hideDatatype=true)
{
if ($hideDatatype && ($t instanceof PHP_UML_Metamodel_Datatype))
return '';
$ns = $t instanceof PHP_UML_Metamodel_Datatype ? '' : self::T_NAMESPACE;
if (isset($t->package)) {
$ns .= $this->getAbsPath($t->package, self::T_NAMESPACE);
}
return $ns.$t->name;
}
/**
* Renders an unresolved type as an HTML span
*
* @param string $type Type, provided as a string
*
* @return string
*/
protected function displayUnresolved($type)
{
return $type;
}
protected function getTagsAsList(PHP_UML_Metamodel_Stereotype $s)
{
return $this->getDocblocks($s, 0);
}
/**
* Renders the properties of a given stereotype.
* Docblocks in $ignoredTag are not shown.
*
* @param PHP_UML_Metamodel_Stereotype $s A stereotype
* @param int $nbSpacer Number of spacers to add
*
* @return string
*/
protected function getDocblocks(PHP_UML_Metamodel_Stereotype $s, $nbSpacer = 0)
{
$str = '';
$spacer = str_repeat(chr(9), $nbSpacer);
foreach ($s->ownedAttribute as $tag) {
if (!(in_array($tag->name, $this->ignoredTag))) {
$str .= $spacer;
if ($tag->name!='description') {
$str .= ' * @'.$tag->name.' ';
} else {
$str .= ' * ';
}
if (strlen($tag->value)>0)
$str .= str_replace($this->getNl(), $this->getNl().$spacer.' * ', $tag->value);
if ($tag->name=='description') {
$str .= $this->getNl().$spacer.' *';
}
$str .= $this->getNl();
}
}
if ($str != '') {
$str = $spacer.'/**'.$this->getNl().$str.$spacer.' */'.$this->getNl();
}
return $str;
}
/**
* Renders the block "Properties" of a package or a class as HTML
*
* @param PHP_UML_Metamodel_NamedElement $p A classifier/a package
*
* @return string
*/
protected function getPropertyBlock(PHP_UML_Metamodel_NamedElement $p)
{
if (empty($p->ownedAttribute))
return '';
$str = '';
$spacer = chr(9);
foreach ($p->ownedAttribute as $o) {
if (!is_null($o->description) && $this->exporter->getDocblocks()) {
// we add var/return docblocks if they are missing
$this->addVarDocblock($o);
$str .= $this->getDocblocks($o->description, 1);
}
$str .= $spacer;
if ($o->isReadOnly)
$str .= 'const ';
else {
$str .= $o->visibility.' ';
if (!$o->isInstantiable)
$str .= 'static ';
}
// type display;
/*if (is_object($o->type))
$str .= $this->getLinkTo($o->type).' ';
else
$str .= $this->displayUnresolved($o->type);*/
if ((!empty($o->name)) && ($o->name[0]!='$' && !$o->isReadOnly))
$str .= '$';
$str .= $o->name.''.$this->getDefaultValue($o).';';
$str .= $this->getNl().$this->getNl();
}
$str .= '';
return $str;
}
private function addVarDocblock(PHP_UML_Metamodel_Property $o)
{
$found = false;
foreach ($o->description->ownedAttribute as $tag) {
if ($tag->name=='var') {
$found = true;
break;
}
}
if (!$found) {
$st = new PHP_UML_Metamodel_Stereotype();
$st->name = 'var';
if (is_object($o->type))
$st->value = $this->getLinkTo($o->type, false);
else
$st->value = $this->displayUnresolved($o->type);
$o->description->ownedAttribute[] = $st;
}
}
private function addReturnDocblock(PHP_UML_Metamodel_Operation $o)
{
$found = false;
foreach ($o->description->ownedAttribute as $tag) {
if ($tag->name=='return') {
$found = true;
break;
}
}
if (!$found) {
$st = new PHP_UML_Metamodel_Stereotype();
$st->name = 'return';
foreach ($o->ownedParameter as $parameter) {
if ($parameter->direction != 'in') {
if (is_object($parameter->type))
$st->value .= $this->getLinkTo($parameter->type, false).' ';
else
$st->value .= $this->displayUnresolved($parameter->type);
}
}
$o->description->ownedAttribute[] = $st;
}
}
/**
* Renders the block "Function" of a package or a classifier as HTML
*
* @param PHP_UML_Metamodel_NamedElement $p A classifier or a package
*
* @return string
*/
protected function getFunctionBlock(PHP_UML_Metamodel_NamedElement $p)
{
if (empty($p->ownedOperation))
return'';
$str = '';
$spacer = chr(9);
foreach ($p->ownedOperation as $o) {
if (!is_null($o->description) && $this->exporter->getDocblocks()) {
$this->addReturnDocblock($o);
$str .= $this->getDocblocks($o->description, 1);
}
$str .= $spacer.($o->visibility).' ';
if (!$o->isInstantiable)
$str .= 'static ';
if ($o->isAbstract)
$str .= 'abstract ';
$str .= 'function '.$o->name;
/*type hint
$return = $this->getReturnParam($o);
if (is_object($return->type))
$str .= $this->getLinkTo($return->type).' ';
else
$str .= $this->displayUnresolved($return->type);*/
$str .= $this->getParameterList($o, true);
if ($o->isAbstract || $p instanceof PHP_UML_Metamodel_Interface)
$str .= ';'.$this->getNl().$this->getNl();
else
$str .= $this->getNl().$spacer.'{'.$this->getNl().
$spacer.'}'.$this->getNl().$this->getNl();
}
$str .= '';
return $str;
}
/**
* Returns the HTML code for the "File" information tag
*
* @param PHP_UML_Metamodel_NamedElement $p An element
*
* @return string
*/
protected function getFileInfo(PHP_UML_Metamodel_NamedElement $p)
{
if (!empty($p->file->package))
return ''.$this->getAbsPath($p->file->package).$p->file->name.'';
else
return '';
}
protected function getNl()
{
return PHP_EOL;
}
/**
* Replace the template's placeholders with their value
*
* @param string $main Main HTML content (generated by PHP_UML)
* @param string $header Navigation HTML content (navig bar)
* @param string $ns Title content
* @param string $name Element name
*
* @return string
*/
protected function replaceInTpl($main, $header, $ns, $name)
{
$str = str_replace('#HEADER', $header, $this->mainTpl);
$str = str_replace('#NAMESPACE', $ns, $str);
$str = str_replace('#DETAIL', $main, $str);
$str = str_replace('#NAME', $this->getTypeName().' '.$name, $str);
return $str;
}
protected function getTemplateDirectory()
{
return dirname(__FILE__).DIRECTORY_SEPARATOR.self::TEMPLATES_DIRNAME;
}
protected function save($elementName, $str)
{
$fic = $this->getContextPackage()->dir.$elementName.'.'.self::FILE_EXT;
file_put_contents($fic, $str);
}
}
?>

View File

@@ -0,0 +1,59 @@
<?php
/**
* PHP_UML
*
* PHP version 5
*
* @category PHP
* @package PHP_UML
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
* @version SVN: $Revision: 136 $
* @link http://pear.php.net/package/PHP_UML
* @since $Date: 2009-12-10 01:35:58 +0100 (jeu., 10 déc. 2009) $
*/
/**
* Implementation of the class renderer
*
* @category PHP
* @package PHP_UML
* @subpackage Output
* @subpackage Php
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
*/
class PHP_UML_Output_Php_DocInterface extends PHP_UML_Output_Php_DocClassifier
{
protected function getTypeName()
{
return 'interface';
}
protected function getStyleName()
{
return 'interface';
}
protected function getPrefix()
{
return self::INTERFACE_PREFIX;
}
protected function getCurrentElement($i)
{
return $this->getContextPackage()->interfaces[$i];
}
protected function getNextElement($i)
{
return $i+1<count($this->getContextPackage()->interfaces) ? $this->getContextPackage()->interfaces[$i+1] : null;
}
protected function getPreviousElement($i)
{
return $i>0 ? $this->getContextPackage()->interfaces[$i-1] : null;
}
}
?>

View File

@@ -0,0 +1,113 @@
<?php
/**
* PHP_UML
*
* PHP version 5
*
* @category PHP
* @package PHP_UML
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
* @version SVN: $Revision: 167 $
* @link http://pear.php.net/package/PHP_UML
* @since $Date: 2011-09-08 02:23:25 +0200 (jeu., 08 sept. 2011) $
*/
/**
* This class generates a HTML website from a UML model (a PHP_UML_Metamodel)
*
* @category PHP
* @package PHP_UML
* @subpackage Output
* @subpackage Php
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
*/
class PHP_UML_Output_Php_Exporter extends PHP_UML_Output_ExporterAPI
{
private $docClass;
private $docInterface;
private $docblocks = true;
/**
* Option to add time/id information as comments
* @param boolean $value
*/
/*public function setStamp($value)
{
$this->stamp = $value;
}
public function getStamp()
{
return $this->stamp;
}*/
/**
* Option to add docblocks
*
* @param boolean $value Set to true to include docblocks
*/
public function setDocblocks($value)
{
$this->docblocks = $value;
}
public function getDocblocks()
{
return $this->docblocks;
}
public function export($outDir)
{
$userCurrentDir = getcwd();
if (substr($outDir, -1) != DIRECTORY_SEPARATOR)
$outDir .= DIRECTORY_SEPARATOR;
parent::export($outDir);
$this->ctx = new PHP_UML_Output_ApiContextPackage();
$this->docClass = new PHP_UML_Output_Php_DocClass($this);
$this->docInterface = new PHP_UML_Output_Php_DocInterface($this);
chdir($outDir);
// we analyse the inheritance/impl relations beforehand:
$this->setAllSuperClassifiers($this->structure->packages);
$this->treatPackage($this->structure->packages);
chdir($userCurrentDir);
}
/**
* Recurses into the packages, and generates the detailed files (one file
* per class/interface/package)
*
* @param PHP_UML_Metamodel_Package $pkg Starting package
* @param string $dir Filepath leading to the current package
* @param string $rpt Relative filepath to the top package
*/
private function treatPackage(PHP_UML_Metamodel_Package $pkg, $dir='', $rpt='')
{
$this->initContextPackage($pkg, $dir, $rpt);
$nbc = count($this->ctx->classes);
$nbi = count($this->ctx->interfaces);
for ($i=0; $i<$nbc; $i++)
$this->docClass->render($i);
for ($i=0; $i<$nbi; $i++)
$this->docInterface->render($i);
foreach ($pkg->nestedPackage as $np) {
$npDir = $dir.$np->name;
if (!file_exists($npDir))
mkdir($npDir);
$this->treatPackage($np, $npDir.DIRECTORY_SEPARATOR, '../'.$rpt);
}
}
}
?>

View File

@@ -0,0 +1,5 @@
<?php
#HEADER
#NAMESPACE
#DETAIL
?>

View File

@@ -0,0 +1,336 @@
<?php
/**
* PHP_UML (PHP_UML_Output_Xmi_AbstractBuilder)
*
* PHP version 5
*
* @category PHP
* @package PHP_UML
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
* @version SVN: $Revision: 166 $
* @link http://pear.php.net/package/PHP_UML
* @since $Date: 2011-09-07 23:20:01 +0200 (mer., 07 sept. 2011) $
*/
/**
* Abstract class to generate UML elements in XMI code.
*
* To deal with the two different versions of XMI (1.4 and 2.1), you must use one of
* the two specialized versions:
* PHP_UML_Output_Xmi_BuilderImpl1, or PHP_UML_Output_Xmi_BuilderImpl2
*
* @category PHP
* @package PHP_UML
* @subpackage Output
* @subpackage Xmi
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
*/
abstract class PHP_UML_Output_Xmi_AbstractBuilder implements PHP_UML_Output_Xmi_Builder
{
const EXPORTER_NAME = 'PEAR\PHP_UML';
const PHP_FILE = 'PHP File';
static protected $allStereotypes = array('File', self::PHP_FILE);
static protected $allExtensions = array(''=>'File', 'php'=>self::PHP_FILE);
protected $xmiVersion = 2;
protected $encoding = 'iso-8859-1';
protected $logicalView = true;
protected $deploymentView = false;
protected $componentView = false;
protected $stereotypes = false;
/**
* Sets the XML encoding
*
* @param string $encoding Encoding
*/
public function setEncoding($encoding)
{
$this->encoding = $encoding;
}
/**
* Enables the inclusion of a logical view in the serialized model
*
* @param boolean $value True/False
*/
public function setLogicalView($value)
{
$this->logicalView = $value;
}
/**
* Enables the inclusion of a deployment view in the serialized model
*
* @param boolean $value True/False
*/
public function setDeploymentView($value)
{
$this->deploymentView = $value;
}
/**
* Enables the inclusion of a component view in the serialized model
*
* @param boolean $value True/False
*/
public function setComponentView($value)
{
$this->componentView = $value;
}
/**
* Enables the inclusion of the stereotypes in the serialized model
*
* @param boolean $value True/False
*/
public function setStereotypes($value)
{
$this->stereotypes = $value;
}
/**
* Generates an ID for an element. A partial identifier can be provided
* (used for classes and their idrefs)
*
* @param string $prefix Prefix
*
* @return string ID
*/
static protected function getUID($prefix = null)
{
if (is_null($prefix))
return PHP_UML_SimpleUID::getUID();
else
return md5(self::EXPORTER_NAME.'#'.$prefix);
}
/**
* Gets an XML header for the XMI file
*
* @return string
*/
protected function getXmlHeader()
{
return '<?xml version="1.0" encoding="'.$this->encoding.'"?>';
}
/**
* Factory method. Retrieves a proper implementation class,
* matching the XMI version.
*
* @param float $version XMI version
*
* @return PHP_UML_Output_Xmi_Builder An XMI builder object
*/
static function getInstance($version)
{
if ($version < 2)
return new PHP_UML_Output_Xmi_BuilderImpl1();
else
return new PHP_UML_Output_Xmi_BuilderImpl2();
}
/**
* Get all packages, recursively, with all the objects they contain
* Initially called by generateXmi() on the root package
*
* @param PHP_UML_Metamodel_Package $package Base package
*
* @return string XMI code
*/
protected function getAllPackages(PHP_UML_Metamodel_Package $package)
{
$str = $this->getPackageOpen($package);
$str .= $this->getNamespaceOpen();
$str .= $this->getOwnedElements($package);
foreach ($package->nestedPackage as $pkg)
$str .= $this->getAllPackages($pkg, false);
$str .= $this->getNamespaceClose();
$str .= $this->getPackageClose();
return $str;
}
/**
* Get the different types owned by a package
*
* @param PHP_UML_Metamodel_Package $package Package to get the types of
*
* @return string XMI code
*/
protected function getOwnedElements(PHP_UML_Metamodel_Package $package)
{
$str = '';
foreach ($package->ownedType as &$elt) {
switch(get_class($elt)) {
case 'PHP_UML_Metamodel_Interface':
$str .= $this->getInterface($elt);
break;
case 'PHP_UML_Metamodel_Datatype':
$str .= $this->getDatatype($elt);
break;
case 'PHP_UML_Metamodel_Artifact':
$str .= $this->getArtifact($elt, $elt->manifested);
break;
default:
$str .= $this->getClass($elt);
}
}
// we will finally not use this since it leads to unvalid XMI:
/*foreach ($package->ownedOperation as &$elt) {
$str .= $this->getOperation($elt);
}
foreach ($package->ownedAttribute as &$elt) {
$str .= $this->getProperty($elt);
}*/
return $str;
}
/**
* Get all components, with its provided classes
* PHP_UML considers each logical package as a component, and each owned class
* as a provided class.
*
* @param PHP_UML_Metamodel_Package $package Package to map to a component
*
* @return string XMI code
*/
protected function getAllComponents(PHP_UML_Metamodel_Package $package)
{
$str = '';
$cv = new PHP_UML_Metamodel_Package;
$cv->id = self::getUID();
$cv->name = $package->name;
$classes = array();
foreach ($package->ownedType as &$elt) {
$classes[] = $elt;
}
$str .= $this->getComponentOpen($cv, $classes, array());
foreach ($package->nestedPackage as $pkg)
$str .= $this->getAllComponents($pkg);
$str .= $this->getComponentClose();
return $str;
}
/**
* Return the full serialized XMI metamodel of a given Superstructure.
*
* @param PHP_UML_Metamodel_Superstructure $structure Full metamodel
*
* @return PHP_UML_Output_XmiDocument The serialized metamodel, as an XmiDocument
*
*/
public function getXmiDocument(PHP_UML_Metamodel_Superstructure $structure)
{
if (empty($structure) || empty($structure->packages)) {
throw new PHP_UML_Exception('No model given');
}
$xmi = $this->getXmlHeader();
$xmi .= $this->getXmiHeaderOpen();
$_root = $structure->packages;
$xmi .= $this->getModelOpen($_root);
$xmi .= $this->getNamespaceOpen();
if ($this->logicalView) {
$xmi .= $this->addLogicalView($_root);
}
if ($this->componentView) {
$xmi .= $this->addComponentView($_root);
}
if ($this->deploymentView) {
$xmi .= $this->addDeploymentView($structure->deploymentPackages);
}
$xmi .= $this->getNamespaceClose();
$xmi .= $this->getModelClose();
if ($this->stereotypes) { // = XML metadata only for the moment
$xmi .= $this->addStereotypeInstances($structure);
}
$xmi .= $this->getXmiHeaderClose();
if (strcasecmp($this->encoding, 'utf-8')==0) {
$xmi = utf8_encode($xmi);
}
$xmiDocument = new PHP_UML_Output_XmiDocument($xmi);
return $xmiDocument;
}
/**
* Return the logical view of the model
*
* @param PHP_UML_Metamodel_Package $package Package
*/
private function addLogicalView(PHP_UML_Metamodel_Package $package)
{
$xmi = $this->getStereotypes();
$xmi .= $this->getOwnedElements($package);
foreach ($package->nestedPackage as $pkg)
$xmi .= $this->getAllPackages($pkg, false);
return $xmi;
}
/**
* Return a component view of the logical system
*
* @param PHP_UML_Metamodel_Package $package Root package to browse into
*/
private function addComponentView(PHP_UML_Metamodel_Package $package)
{
return $this->getAllComponents($package);
}
/**
* Return a deployment view of the scanned files.
* A file is viewed as an artifact (artifacts exist from UML 1.4)
* Filesystem's folders are treated as packages.
* TODO: use a package-tree, like with logical packages
*
* @param PHP_UML_Metamodel_Package $package The root deployment package
*/
private function addDeploymentView(PHP_UML_Metamodel_Package $package)
{
return $this->getAllPackages($package);
}
/**
* Return the instances of stereotypes
* At the current time, there are only XML metadata, not real UML stereotypes
*
* @param PHP_UML_Metamodel_Superstructure $structure Metamodel
*/
private function addStereotypeInstances(PHP_UML_Metamodel_Superstructure $structure)
{
$xmi = '';
foreach ($structure->stereotypes as $s) {
$xmi .= $this->getStereotypeInstance($s);
}
return $xmi;
}
}
?>

View File

@@ -0,0 +1,251 @@
<?php
/**
* PHP_UML (interface PHP_UML_Output_Xmi_Builder)
*
* PHP version 5
*
* @category PHP
* @package PHP_UML
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
* @version SVN: $Revision: 138 $
* @link http://pear.php.net/package/PHP_UML
* @since $Date: 2009-12-13 04:23:11 +0100 (dim., 13 déc. 2009) $
*/
/**
* Interface for the XMI generation
*
* @category PHP
* @package PHP_UML
* @subpackage Output
* @subpackage Xmi
*/
interface PHP_UML_Output_Xmi_Builder
{
/**
* Retrievesthe XMI header
*
* @return string XMI code
*/
function getXmiHeaderOpen();
/**
* Closing tag for the XMI header
*
* @return string XMI code
*/
function getXmiHeaderClose();
/**
* Retrieves the opening tag for a model
*
* @param string $model Root package
*
* @return string XMI code
*/
function getModelOpen(PHP_UML_Metamodel_Package $model);
/**
* Retrieves the closing tag of a model
*
* @return string XMI code
*/
function getModelClose();
/**
* Retrieves the opening tag for a package
*
* @param PHP_UML_Metamodel_Package $package Package to insert
*
* @return string XMI code
*/
function getPackageOpen(PHP_UML_Metamodel_Package $package);
/**
* Retrieves the closing tag of a package
*
* @return string XMI code
*/
function getPackageClose();
/**
* Retrieves the opening namespace tag (XMI 1 only)
*
* @return string XMI code
*/
function getNamespaceOpen();
/**
* Retrieves the closing namespace tag (XMI 1 only)
*
* @return string XMI code
*/
function getNamespaceClose();
/**
* Retrieves the opening tag for a sub-system (XMI 1), or a component (XMI 2)
*
* @param PHP_UML_Metamodel_Package $package Package to code as a subsystem
*
* @return string XMI code
*/
public function getSubsystemOpen(PHP_UML_Metamodel_Package $package);
/**
* Retrieves the closing tag for a subsystem / component
*
* @return string XMI code
*/
function getSubsystemClose();
/**
* Retrieves the necessary stereotypes
*
* @return string XMI code
*/
function getStereotypes();
/**
* Retrieves the XMI code for a given stereotype
*
* @param PHP_UML_Metamodel_Stereotype $s Stereotype
*/
function getStereotypeInstance(PHP_UML_Metamodel_Stereotype $s);
/**
* Retrieves the XMI declarations of the main PHP types
*
* @param PHP_UML_Datatype $type Datatype
*
* @return string XMI code
*/
function getDatatype(PHP_UML_Metamodel_Datatype $type);
/**
* Retrieves the XMI code for a class
*
* @param PHP_UML_Metamodel_Class $class Class
*
* @return string XMI code
*/
function getClass(PHP_UML_Metamodel_Class $class);
/**
* Retrieves the XMI code for an interface
*
* @param PHP_UML_Metamodel_Interface $interface Class
*
* @return string XMI code
*/
function getInterface(PHP_UML_Metamodel_Interface $interface);
/**
* Retrieves the XMI code for an operation
*
* @param PHP_UML_Metamodel_Operation $operation Operation
*
* @return string XMI code
*/
function getOperation(PHP_UML_Metamodel_Operation $operation);
/**
* Retrieves the XMI code for the paramater of an operation
*
* @param PHP_UML_Metamodel_Parameter $parameter Parameter
*
* @return string XMI code
*/
function getParameter(PHP_UML_Metamodel_Parameter $parameter);
/**
* Retrieves the XMI code for an artifact
*
* @param PHP_UML_Metamodel_Artifact $file File to add as an artifact
* @param array &$mf Manifested elements
* (array of PHP_UML_Metamodel_Class)
*
* @return string XMI code
*/
function getArtifact(PHP_UML_Metamodel_Artifact $file, &$mf = array());
/**
* Retrieves the XMI code for a component
*
* @param PHP_UML_Metamodel_Package $package Package to add as a component
* @param array $provided Set of providing classes
* @param array $required Set of required classes (TODO)
*
* @return string XMI code
*/
function getComponentOpen(PHP_UML_Metamodel_Package $package, array $provided, array $required);
/**
* Retieves the closing tag for a component
*
* @return string XMI code
*/
function getComponentClose();
/**
* Retrieves the XMI code for a classifier (datatype, class, interface)
* Required by getParameter(). Adds the default value (if any)
*
* @param PHP_UML_Metamodel_TypedElement $parameter Element (datatype, class..)
*
* @return string XMI code
*/
function getParameterType(PHP_UML_Metamodel_TypedElement $parameter);
/**
* Retrieves the XMI code for all the realization (= interface implementations)
* of a given element
*
* @param PHP_UML_Metamodel_Class $client Child element
*
* @return string XMI code
*/
function getRealizations(PHP_UML_Metamodel_Class $client);
/**
* Retrieves the XMI code for all the inherited classes of a given element
*
* @param PHP_UML_Metamodel_Type $client Child element
*
* @return mixed In XMI 1.x, this returns an array, because XMI 1 needs two
* declarations: the child element must be defined as "generalizable", in
* addition to the generalization relationship. In XMI 2, only the relationship
* is necessary, which is returned as a string.
*/
function getGeneralizations(PHP_UML_Metamodel_Type $client);
/**
* Adds a description/comment to a model element
* The description is given through a stereotype instance
*
* @param PHP_UML_Metamodel_Stereotype $s A stereotype object
* @param string $annotatedElement The commented element
*
* @return string XMI code
*/
function getComment(PHP_UML_Metamodel_Stereotype $s, $annotatedElement='');
/**
* Retrieves the XMI code for a UML2 profile.
*
* @return string XMI code
*/
function getProfile();
/**
* Retrieves the metadata related to a given tag
*
* @param PHP_UML_Metamodel_Tag $tag Tag
*
* @return string XMI code
*/
public function getMetadata(PHP_UML_Metamodel_Tag $tag);
}
?>

View File

@@ -0,0 +1,417 @@
<?php
/**
* PHP_UML (PHP_UML_Output_Xmi_BuilderImpl1)
*
* PHP version 5
*
* @category PHP
* @package PHP_UML
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
* @version SVN: $Revision: 174 $
* @link http://pear.php.net/package/PHP_UML
* @since $Date: 2011-09-15 03:17:32 +0200 (jeu., 15 sept. 2011) $
*/
/**
* Implementation class to create XMI in version 1
*
* See the interface PHP_UML_Output_Xmi_Builder for the comments
*
* @category PHP
* @package PHP_UML
* @subpackage Output
* @subpackage Xmi
* @see PHP_UML_Output_Xmi_Builder
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
*/
class PHP_UML_Output_Xmi_BuilderImpl1 extends PHP_UML_Output_Xmi_AbstractBuilder
{
const XMI_VERSION = '1.2';
const UML_VERSION = '1.4';
const DEFAULT_CLASSIFIER_ATT = ' visibility="public" isAbstract="false"
isSpecification="false" isRoot="false" isLeaf="false" ';
public function getXmiHeaderOpen()
{
return '<XMI xmi.version="'.self::XMI_VERSION.'"
xmlns:UML="http://www.omg.org/spec/UML/1.4">
<XMI.header>
<XMI.documentation>
<XMI.exporter>'.self::EXPORTER_NAME.'</XMI.exporter>
</XMI.documentation>
<XMI.metamodel XMI.name="UML" XMI.version="'.self::XMI_VERSION.'" />
</XMI.header>
<XMI.content>';
}
public function getXmiHeaderClose()
{
return '</XMI.content></XMI>';
}
public function getModelOpen(PHP_UML_Metamodel_Package $model)
{
return '<UML:Model name="'.$model->name.'" xmi.id="'.$model->id.'" '.
self::DEFAULT_CLASSIFIER_ATT.'>';
}
public function getStereotypes()
{
$str = '';
foreach (self::$allStereotypes as $item)
$str .= '<UML:Stereotype xmi.id="'.self::getUID('stereotype_'.$item).'"
name="'.$item.'" '.self::DEFAULT_CLASSIFIER_ATT.' />';
$str .= '<UML:Stereotype xmi.id="'.self::getUID('stereotype_realize').'"
name="realize" '.self::DEFAULT_CLASSIFIER_ATT.'>
<UML:Stereotype.baseClass>Abstraction</UML:Stereotype.baseClass>
</UML:Stereotype>';
$str .= $this->getTagDefinition('documentation');
return $str;
}
public function getStereotypeInstance(PHP_UML_Metamodel_Stereotype $s)
{
return '';
}
public function getMetadata(PHP_UML_Metamodel_Tag $tag)
{
return '<'.$tag->name.'>'.$tag->value.'</'.$tag->name.'>';
}
public function getModelClose()
{
return '</UML:Model>';
}
public function getPackageOpen(PHP_UML_Metamodel_Package $package)
{
$str = '<UML:Package xmi.id="'.$package->id.'" name="'.$package->name.'">';
if (isset($package->description)) {
$str .= $this->getComment($package->description);
}
return $str;
}
public function getNamespaceOpen()
{
return '<UML:Namespace.ownedElement>';
}
public function getPackageClose()
{
return '</UML:Package>';
}
public function getNamespaceClose()
{
return '</UML:Namespace.ownedElement>';
}
public function getSubsystemOpen(PHP_UML_Metamodel_Package $package)
{
return '<UML:Subsystem name="'.$package->name.'" xmi.id="'.
$package->id.'" isInstantiable="false"><UML:Namespace.ownedElement>';
}
public function getSubsystemClose()
{
return '</UML:Namespace.ownedElement></UML:Subsystem>';
}
public function getDatatype(PHP_UML_Metamodel_Datatype $type)
{
$str = '<UML:DataType xmi.id="'.$type->id.'"'.
' name="'.$type->name.'" visibility="public" isRoot="false" '.
' isLeaf="false" isAbstract="false">';
if (isset($class->description))
$str .= $this->getComment($class->description);
return $str.'</UML:DataType>';
}
public function getClass(PHP_UML_Metamodel_Class $class)
{
$str = '<UML:Class name="'.$class->name.'" xmi.id="'.
$class->id.'" visibility="package"
isAbstract="'.($class->isAbstract?'true':'false').'">';
list($generalizable, $generalization) = $this->getGeneralizations($class);
$str .= $generalizable;
$str .= '<UML:Classifier.feature>';
foreach ($class->ownedAttribute as &$property) {
$str .= $this->getProperty($property);
}
foreach ($class->ownedOperation as &$operation) {
$str .= $this->getOperation($operation);
}
$str .= '</UML:Classifier.feature>';
if (isset($class->description))
$str .= $this->getComment($class->description);
$str .= '</UML:Class>';
return $str.$generalization.$this->getRealizations($class);
}
public function getInterface(PHP_UML_Metamodel_Interface $interface)
{
$str = '<UML:Interface name="'.$interface->name.'"'.
' xmi.id="'.$interface->id.'"'.
' visibility="package" isAbstract="true">';
list($generalizable, $generalization) = $this->getGeneralizations($interface);
$str .= $generalizable;
$str .= '<UML:Classifier.feature>';
foreach ($interface->ownedOperation as &$operation)
$str .= $this->getOperation($operation);
$str .= '</UML:Classifier.feature>';
if (isset($interface->description))
$str .= $this->getComment($interface->description);
$str .= '</UML:Interface>';
return $str.$generalization;
}
public function getGeneralizations(PHP_UML_Metamodel_Type $client)
{
$str = '';
$generalizable = '';
$generalization = '';
foreach ($client->superClass as &$gclass) {
if (is_object($gclass)) {
$id = self::getUID();
$generalizable .= '<UML:GeneralizableElement.generalization>
<UML:Generalization xmi.idref="'.$id.'"/>
</UML:GeneralizableElement.generalization>';
$generalization .= '<UML:Generalization xmi.id="'.$id.'">
<UML:Generalization.child><UML:Class xmi.idref="'.
$client->id.
'" /></UML:Generalization.child>
<UML:Generalization.parent><UML:Class xmi.idref="'.
$gclass->id.'"/>
</UML:Generalization.parent></UML:Generalization>';
}
}
return array($generalizable, $generalization);
}
public function getRealizations(PHP_UML_Metamodel_Class $client)
{
$str = '';
foreach ($client->implements as &$rclass) {
if (is_object($rclass)) {
$str .= '<UML:Abstraction '.
'xmi.id="'.self::getUID().'" isSpecification="false">'.
'<UML:ModelElement.stereotype><UML:Stereotype xmi.idref="'.
self::getUID('stereotype_realize').'"/>'.
'</UML:ModelElement.stereotype>'.
'<UML:Dependency.client><UML:Class xmi.idref="'.
$client->id.
'"/></UML:Dependency.client>'.
'<UML:Dependency.supplier><UML:Interface xmi.idref="'.
$rclass->id.'"/>'.
'</UML:Dependency.supplier></UML:Abstraction>';
}
}
return $str;
}
public function getProperty(PHP_UML_Metamodel_Property $property)
{
$str = '<UML:Attribute xmi.id="'.$property->id.'"'.
' name="'.$property->name.'" '.
' visibility="'.$property->visibility.'" ';
if (!$property->isInstantiable) {
$str .= ' isStatic="true" ownerScope="classifier"';
} else {
$str .= ' ownerScope="instance"';
}
if ($property->isReadOnly)
$str .= ' changeability="frozen" isReadOnly="true" ';
$str .= '>';
$str .= self::getStructuralFeatureType($property);
if (isset($property->description))
$str .= $this->getComment($property->description);
$str .= '</UML:Attribute>';
return $str;
}
public function getOperation(PHP_UML_Metamodel_Operation $operation)
{
$str = '<UML:Operation xmi.id="'.$operation->id.'"'.
' name="'.$operation->name.'"'.
' visibility="'.$operation->visibility.'"';
if (!$operation->isInstantiable)
$str .= ' isStatic="true"';
if ($operation->isAbstract)
$str .= ' isAbstract="true"';
$str .= ' isQuery="false" concurrency="sequential">'.
'<UML:BehavioralFeature.parameter>';
foreach ($operation->ownedParameter as &$parameter) {
$str .= $this->getParameter($parameter);
}
$str .= '</UML:BehavioralFeature.parameter>';
if (isset($operation->description))
$str .= $this->getComment($operation->description);
$str .= '</UML:Operation>';
return $str;
}
public function getParameter(PHP_UML_Metamodel_Parameter $parameter)
{
return '<UML:Parameter xmi.id="'.$parameter->id.'" '.
' name="'.$parameter->name.'"'.
' kind="'.$parameter->direction.'">'.
$this->getParameterType($parameter).
'</UML:Parameter>';
}
public function getParameterType(PHP_UML_Metamodel_TypedElement $parameter)
{
$str = '';
$id = self::getUID();
// Exception to MOF : a PHP class can have the name of a datatype
if (isset($parameter->type->id)) {
$str .= '<UML:Parameter.type>'.
'<UML:DataType xmi.idref="'.$parameter->type->id.
'"/></UML:Parameter.type>';
}
if ($parameter->default!='') {
$str .= '<UML:Parameter.defaultValue>'.
'<UML:Expression xmi.id="'.$id.'"'.
' body="'.htmlspecialchars($parameter->default, ENT_QUOTES).'" />'.
'</UML:Parameter.defaultValue>';
}
return $str;
}
public function getArtifact(PHP_UML_Metamodel_Artifact $file, &$mf = array())
{
return '<UML:Artifact '.
' xmi.id="'.$file->id.'"'.
' name="'.basename(htmlspecialchars($file->name)).'">'.
'<UML:ModelElement.stereotype>'.
'<UML:Stereotype xmi.idref="'.self::getUID('stereotype_'.self::PHP_FILE).'"/>'.
'</UML:ModelElement.stereotype>'.
'</UML:Artifact>';
}
public function getComponentOpen(PHP_UML_Metamodel_Package $package, array $provided, array $required)
{
return self::getSubsystemOpen($package);
}
public function getComponentClose()
{
return self::getSubsystemClose();
}
public function getComment(PHP_UML_Metamodel_Stereotype $s, $annotatedElement='')
{
$tag = PHP_UML_Metamodel_Helper::getStereotypeTag($s, 'description');
if(!is_null($tag))
return $this->getTaggedValue($tag->value, self::getUID('Tag_documentation'));
else
return '';
}
public function getTaggedValue($value, $tag)
{
return '<UML:ModelElement.taggedValue>'.
'<UML:TaggedValue xmi.id="'.self::getUID().'" visibility="public">'.
'<UML:TaggedValue.dataValue>'.htmlspecialchars($value).'</UML:TaggedValue.dataValue>'.
'<UML:TaggedValue.type>'.
'<UML:TagDefinition xmi.idref="'.$tag.'"/>'.
'</UML:TaggedValue.type>'.
'</UML:TaggedValue>'.
'</UML:ModelElement.taggedValue>';
}
public function getTagDefinition($name)
{
return '<UML:TagDefinition xmi.id="'.self::getUID('Tag_'.$name).'" '.
'name="'.$name.'" isSpecification="false" tagType="string">
<UML:TagDefinition.multiplicity>
<UML:Multiplicity xmi.id="'.self::getUID('TagMultiplicity_'.$name).'">
<UML:Multiplicity.range>
<UML:MultiplicityRange xmi.id="'.self::getUID('TagMultiRange_'.$name).'"
lower="0" upper="1"/>
</UML:Multiplicity.range>
</UML:Multiplicity>
</UML:TagDefinition.multiplicity>
</UML:TagDefinition>';
}
public function getProfile()
{
}
/**
* Get the structural type of an element (XMI 1.x)
*
* @param PHP_UML_TypedElement $element Element
*
* @return string XMI code
*/
static protected function getStructuralFeatureType(PHP_UML_Metamodel_TypedElement $element)
{
$str = '';
$id = self::getUID();
if (!is_object($element->type))
return '';
if (get_class($element->type)=='PHP_UML_Metamodel_Class') {
$str .= '<UML:StructuralFeature.type>'.
'<UML:DataType xmi.idref="'.$element->type->id.
'"/></UML:StructuralFeature.type>';
} elseif (get_class($element->type)=='PHP_UML_Metamodel_Datatype') {
$str .= '<UML:StructuralFeature.type>'.
'<UML:DataType xmi.idref="'.$element->type->id.
'"/></UML:StructuralFeature.type>';
}
if ($element->default!='') {
$str .= '<UML:Attribute.initialValue>'.
'<UML:Expression xmi.id="'.$id.'"'.
' body="'.htmlspecialchars($element->default, ENT_QUOTES).'" />'.
'</UML:Attribute.initialValue>';
}
return $str;
}
}
?>

View File

@@ -0,0 +1,388 @@
<?php
/**
* PHP_UML (PHP_UML_Output_Xmi_BuilderImpl2)
*
* PHP version 5
*
* @category PHP
* @package PHP_UML
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
* @version SVN: $Revision: 174 $
* @link http://pear.php.net/package/PHP_UML
* @since $Date: 2011-09-15 03:17:32 +0200 (jeu., 15 sept. 2011) $
*/
/**
* Implementation class to create XMI in version 2
*
* See the interface PHP_UML_Output_Xmi_Builder for the comments.
*
* @category PHP
* @package PHP_UML
* @subpackage Output
* @subpackage Xmi
* @see PHP_UML_Output_Xmi_Builder
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
*/
class PHP_UML_Output_Xmi_BuilderImpl2 extends PHP_UML_Output_Xmi_AbstractBuilder
{
const XMI_VERSION = '2.1';
const UML_VERSION = '2.1.2';
const DEFAULT_CLASSIFIER_ATT = ' visibility="public" isAbstract="false" ';
/**
* PHP_UML UML Profile (TODO)
* @var string
*/
public $profile = '';
public function getXmiHeaderOpen()
{
return '<xmi:XMI xmi:version="'.self::XMI_VERSION.'"
xmlns:uml="http://schema.omg.org/spec/UML/'.self::UML_VERSION.'"
xmlns:xmi="http://schema.omg.org/spec/XMI/'.self::XMI_VERSION.'"
xmlns:php="http://schemas/phpdoc/'.self::getUID().'">
<xmi:Documentation exporter="'.self::EXPORTER_NAME.'"/>';
}
public function getModelOpen(PHP_UML_Metamodel_Package $model)
{
return '<uml:Model xmi:type="uml:Model" name="'.$model->name.'"
xmi:id="'.$model->id.'" '.self::DEFAULT_CLASSIFIER_ATT.'>';
}
public function getModelClose()
{
return '</uml:Model>';
}
public function getXmiHeaderClose()
{
return '</xmi:XMI>';
}
public function getPackageOpen(PHP_UML_Metamodel_Package $package)
{
$str = '<packagedElement xmi:type="uml:Package" xmi:id="'.$package->id.
'" name="'.$package->name.'">';
if (isset($package->description)) {
$str .= $this->getComment($package->description, $package->id);
}
return $str;
}
public function getPackageClose()
{
return '</packagedElement>';
}
public function getNamespaceOpen()
{
return '';
}
public function getNamespaceClose()
{
return '';
}
public function getDatatype(PHP_UML_Metamodel_Datatype $type)
{
$str = '<packagedElement xmi:type="uml:DataType"'.
' xmi:id="'.$type->id.'"'.
' name="'.$type->name.'">';
if (isset($type->description))
$str .= $this->getComment($type->description, $type->id);
return $str.'</packagedElement>';
}
public function getSubsystemOpen(PHP_UML_Metamodel_Package $package)
{
return '<packagedElement xmi:type="uml:Component" xmi:id="'.
$package->id.'" name="'.$package->name.
'" '.self::DEFAULT_CLASSIFIER_ATT.'>';
}
public function getSubsystemClose()
{
return '</packagedElement>';
}
public function getClass(PHP_UML_Metamodel_Class $class)
{
$strRealization = '';
$str = '<packagedElement xmi:type="uml:Class" name="'.$class->name.'" xmi:id="'.
$class->id.'" visibility="package"
isAbstract="'.($class->isAbstract?'true':'false').'">';
$str .= $this->getGeneralizations($class);
$strRealization .= $this->getRealizations($class);
foreach ($class->ownedAttribute as &$property)
$str .= $this->getProperty($property);
foreach ($class->ownedOperation as &$operation)
$str .= $this->getOperation($operation);
if (isset($class->description))
$str .= $this->getComment($class->description, $class->id);
$str .= '</packagedElement>';
return $str.$strRealization;
}
public function getInterface(PHP_UML_Metamodel_Interface $interface)
{
$str = '<packagedElement xmi:type="uml:Interface" '.
' name="'.$interface->name.'" xmi:id="'.$interface->id.'"'.
' visibility="package" isAbstract="true">';
foreach ($interface->ownedOperation as &$operation)
$str .= $this->getOperation($operation);
$str .= $this->getGeneralizations($interface);
if (isset($interface->description))
$str .= $this->getComment($interface->description, $interface->id);
$str .= '</packagedElement>';
return $str;
}
public function getRealizations(PHP_UML_Metamodel_Class $client)
{
$str = '';
foreach ($client->implements as &$rclass) {
if (is_object($rclass)) {
$str .= '<packagedElement xmi:type="uml:Realization" '.
'xmi:id="'.self::getUID().'" '.
'client="'.$client->id.'" '.
'supplier="'.$rclass->id.'" '.
'realizingClassifier="'.$rclass->id.'"/>';
}
}
return $str;
}
public function getGeneralizations(PHP_UML_Metamodel_Type $client)
{
$str = '';
foreach ($client->superClass as &$gclass) {
if (is_object($gclass)) {
$str .= '<generalization xmi:type="uml:Generalization" '.
'xmi:id="'.self::getUID().'" '.
'general="'.$gclass->id.'"/> ';
}
}
return $str;
}
public function getProperty(PHP_UML_Metamodel_Property $property)
{
$str = '<ownedAttribute xmi:type="uml:Property"'.
' name="'.$property->name.'"'.
' xmi:id="'.$property->id.'"'.
' visibility="'.$property->visibility.'" ';
if (!$property->isInstantiable)
$str .= ' isStatic="true"';
if ($property->isReadOnly)
$str .= ' isReadOnly="true" ';
$str .= '>'.$this->getParameterType($property);
if (isset($property->description))
$str .= $this->getComment($property->description, $property->id);
$str .= '</ownedAttribute>';
return $str;
}
public function getOperation(PHP_UML_Metamodel_Operation $operation)
{
$str = '<ownedOperation xmi:id="'.$operation->id.'"
name="'.$operation->name.'" visibility="'.$operation->visibility.'" ';
if (!$operation->isInstantiable)
$str .= ' isStatic="true"';
if ($operation->isAbstract)
$str .= ' isAbstract="true"';
$str .= '>';
foreach ($operation->ownedParameter as &$parameter) {
$str .= $this->getParameter($parameter);
}
if (isset($operation->description))
$str .= $this->getComment($operation->description, $operation->id);
$str .= '</ownedOperation>';
return $str;
}
public function getParameter(PHP_UML_Metamodel_Parameter $parameter)
{
return '<ownedParameter xmi:id="'.$parameter->id.'" '.
'name="'.$parameter->name.'" direction="'.$parameter->direction.'">'.
$this->getParameterType($parameter).
'</ownedParameter>';
}
public function getParameterType(PHP_UML_Metamodel_TypedElement $parameter)
{
$str = '';
$id = self::getUID();
if (isset($parameter->type->id))
$str = '<type xmi:idref="'.$parameter->type->id.'"/>';
if ($parameter->default!='')
$str .= '<defaultValue xmi:type="uml:LiteralString" xmi:id="'.$id.'"'.
' value="'.htmlspecialchars($parameter->default, ENT_QUOTES).'" />';
return $str;
}
public function getArtifact(PHP_UML_Metamodel_Artifact $file, &$mf = array())
{
$id = $file->id;
$file = htmlspecialchars($file->name);
$name = basename($file);
$str = '
<packagedElement xmi:type="uml:Artifact"'.
' xmi:id="'.$id.'"'.
' name="'.$name.'" '.
' stereotype="'.self::getUID('stereotype_'.self::PHP_FILE).'" '.
self::DEFAULT_CLASSIFIER_ATT.' >';
foreach ($mf as $class) {
if ($class instanceof PHP_UML_Metamodel_Classifier) {
$id_supplier = $class->id;
$str .= self::getManifestation($id, $id_supplier, 'source');
}
}
$str .= '</packagedElement>';
return $str;
}
public function getComponentOpen(PHP_UML_Metamodel_Package $package, array $provided, array $required)
{
$str = '
<packagedElement xmi:type="uml:Component"'.
' xmi:id="'.$package->id.'"'.
' name="'.$package->name.'" '.
self::DEFAULT_CLASSIFIER_ATT.' >';
foreach ($provided as $c) {
switch (get_class($c)) {
case 'PHP_UML_Metamodel_Interface':
case 'PHP_UML_Metamodel_Class':
$id = self::getUID('CV_provided_'.$c->name);
$id_provided = $c->id;
$str .= '<provided xmi:id="'.$id.'" xmi:idref="'.$id_provided.
'" name="'.$c->name.'"/>';
}
}
foreach ($required as $c) {
$id = self::getUID('CV_required_'.$c->name);
$id_provided = $c->id;
$str .= '<required xmi:id="'.$id.'" xmi:idref="'.$id_provided.'" name="'.$c->name.'"/>';
}
return $str;
}
public function getComponentClose()
{
return '</packagedElement>';
}
/**
* Formates a Profile adapted to PHP_UML.
*
* TODO. Experimental.
*
* @return string XMI Code
*/
public function getProfile()
{
return file_get_contents('../Metamodel/phpdoc.profile.xmi').
'<profileApplication xmi:type="uml:ProfileApplication" xmi:id="'.self::getUID().'">'.
'<appliedProfile xmi:idref="PHP_UML_phpdoc_1"/>'.
'</profileApplication>';
}
public function getComment(PHP_UML_Metamodel_Stereotype $s, $annotatedElement='')
{
$tag = PHP_UML_Metamodel_Helper::getStereotypeTag($s, 'description');
if(!is_null($tag))
return '<ownedComment xmi:type="uml:Comment"
xmi:id="'.self::getUID().'" annotatedElement="'.$annotatedElement.
'"><body>'.htmlspecialchars($tag->value).'</body></ownedComment>';
else
return '';
}
public function getStereotypes()
{
return '';
}
/**
* Gets all the elements contained in a stereotype
* Note: the property "documentation" is not discarded (we will have
* it as an "ownedComent" tag, instead; see getComment())
*
* @param PHP_UML_Metamodel_Stereotype $s Stereotype
*
* @return string
*/
public function getStereotypeInstance(PHP_UML_Metamodel_Stereotype $s)
{
$str = '';
foreach ($s->ownedAttribute as $tag) {
if($tag->value!='' && $tag->name!='description')
$str .= $this->getMetadata($tag);
}
if ($str!='')
return '<'.$s->profile.':'.$s->name.
' base_Element="'.$s->element->id.'">'.
$str.'</'.$s->profile.':'.$s->name.'>';
else
return '';
}
public function getMetadata(PHP_UML_Metamodel_Tag $tag)
{
return '<'.$tag->name.'>'.htmlspecialchars($tag->value).'</'.$tag->name.'>';
}
/**
* Generates a manifestation element (= the link between a class and the
* artifact where the class is defined)
*
* @param string $client Name of the client
* @param string $supplier Name of the supplier
* @param string $name Name of the relation
*
* @return string XMI code
*/
public function getManifestation($client, $supplier, $name)
{
return '<manifestation xmi:type="uml:Manifestation" '.
'xmi:id="'.self::getUID().'" '.
'client="'.$client.'" supplier="'.$supplier.'" '.
'utilizedElement="'.$supplier.'" name="'.$name.'"/>';
}
}
?>

View File

@@ -0,0 +1,247 @@
<?php
/**
* PHP_UML
*
* PHP version 5
*
* @category PHP
* @package PHP_UML
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
* @version SVN: $Revision: 176 $
* @link http://pear.php.net/package/PHP_UML
* @since $Date: 2011-09-19 00:03:11 +0200 (lun., 19 sept. 2011) $
*/
/**
* This class generates the XMI from a UML model (PHP_UML_Metamodel)
*
* @category PHP
* @package PHP_UML
* @subpackage Output
* @subpackage Xmi
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
*/
class PHP_UML_Output_Xmi_Exporter extends PHP_UML_Output_ExporterAPI
{
/**
* Reference to an XmiDocument object. Such an object is needed by the export()
* method of Xmi_Exporter and its subclasses (unlike the ExporterAPI implementations,
* which work on the metamodel directly, and don't need to know anything about XMI).
*
* @var PHP_UML_Output_XmiDocument
*/
protected $xmiDocument;
/**
* Default XMI version used for serialization. Note that all XSL-based
* exporters will generate XMI with the default xmiVersion and encoding.
*
* @var float
*/
protected $xmiVersion = 2;
/**
* Default XML encoding of the XMI document.
*
* @var string
*/
protected $encoding = 'iso-8859-1';
/**
* A logical view is included in the model by default.
*
* @var boolean
*/
protected $logicalView = true;
/**
* A deployment view is not included in the model by default.
*
* @var boolean
*/
protected $deploymentView = false;
/**
* A component view is not included in the model by default.
*
* @var boolean
*/
protected $componentView = false;
/**
* Stereotypes are not included in the model by default.
*
* @var boolean
*/
protected $stereotypes = false;
/**
* Setter for the XML encoding
*
* @param string $encoding Encoding
*/
public function setEncoding($encoding)
{
$this->encoding = $encoding;
}
/**
* Setter for the XMI version
*
* @param float $version XMI version
*/
public function setXmiVersion($version)
{
$this->xmiVersion = $version;
}
/**
* Enables the inclusion of a logical view in the serialized model
*
* @param boolean $value True/False
*/
public function setLogicalView($value)
{
$this->logicalView = $value;
}
/**
* Enables the inclusion of a deployment view in the serialized model
*
* @param boolean $value True/False
*/
public function setDeploymentView($value)
{
$this->deploymentView = $value;
}
/**
* Enables the inclusion of a component view in the serialized model
*
* @param boolean $value True/False
*/
public function setComponentView($value)
{
$this->componentView = $value;
}
/**
* Enables the inclusion of the stereotypes in the serialized model
* If true, all the stereotypes related to the UML model (currently, these
* data correspond to the PHP docblocks) will be added to the XMI model.
*
* @param boolean $value True/False
*/
public function setStereotypes($value)
{
$this->stereotypes = $value;
}
/**
* Setter for the XmiDocument
*
* @param PHP_UML_Output_XmiDocument $xmiDocument XMI Document
*/
public function setXmiDocument(PHP_UML_Output_XmiDocument $xmiDocument)
{
$this->xmiDocument = $xmiDocument;
}
/**
* Getter for the XmiDocument
*
* @return PHP_UML_Output_XmiDocument
*/
public function getXmiDocument()
{
return $this->xmiDocument;
}
public function export($outDir)
{
if (empty($this->structure))
throw new PHP_UML_Exception('No model given.');
//if (empty($this->xmiDocument)) {
$this->generateXmi();
//}
if ($outDir=='')
return $this->xmiDocument->dump();
else {
if (!is_dir($outDir))
$this->save($outDir);
else
{
$fileName = empty($this->structure->packages) ? 'undefined' : $this->structure->packages->name;
$this->save($outDir.DIRECTORY_SEPARATOR.$fileName.'.xmi');
}
}
}
/**
* Internal method to save the generated XMI to a file.
* Use export() instead if you need to save from outside the Exporter object.
*
* @param string $outputFile Filename
*/
protected function save($outputFile)
{
if ($ptr = fopen($outputFile, 'w+')) {
fwrite($ptr, $this->xmiDocument->dump());
fclose($ptr);
} else {
throw new PHP_UML_Exception(
'File '.$outputFile.' could not be created.'
);
}
}
/**
* Serialize the metamodel (contained in the property $structure) into XMI code
*
* It is not necessary to call this method before calling export();
*/
public function generateXmi()
{
$builder = $this->getXmiBuilder();
$this->xmiDocument = $builder->getXmiDocument($this->structure);
}
/**
* Getter for the XMI factory
*
* @return PHP_UML_Output_Xmi_Builder An XMI builder object
*/
protected function getXmiBuilder()
{
$builder = PHP_UML_Output_Xmi_AbstractBuilder::getInstance($this->xmiVersion);
$builder->setEncoding($this->encoding);
$builder->setLogicalView($this->logicalView);
$builder->setComponentView($this->componentView);
$builder->setDeploymentView($this->deploymentView);
$builder->setStereotypes($this->stereotypes);
return $builder;
}
/**
* 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);
}
}
?>

View File

@@ -0,0 +1,86 @@
<?php
/**
* PHP_UML
*
* PHP version 5
*
* @category PHP
* @package PHP_UML
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
* @version SVN: $Revision: 175 $
* @link http://pear.php.net/package/PHP_UML
* @since $Date: 2011-09-15 17:07:58 +0200 (jeu., 15 sept. 2011) $
*/
/**
* Wrapper for an XMI document
*
* @category PHP
* @package PHP_UML
* @subpackage Output
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
*/
class PHP_UML_Output_XmiDocument
{
/**
* The XMI code of the XMI document
* @var string
*/
private $xmi;
/**
* Constructor
*
* @param string $code XMI code as string
*/
public function __construct($code = '')
{
$this->xmi = $code;
}
/**
* Return the code XMI as a string
*/
public function dump()
{
return $this->xmi;
}
/**
* Load XMI from a file
*
* @param string $filepath Filepath
*/
public function load($filepath)
{
if (file_exists($filepath)) {
$this->xmi = file_get_contents($filepath);
} else {
throw new PHP_UML_Exception('Could not open '.$filepath);
}
$xmlDom = new DomDocument;
$xmlDom->loadXML($this->xmi);
if (self::isVersion1($xmlDom)) {
$this->xmi = PHP_UML_Output_ExporterXSL::convertTo2($this->xmi);
}
}
/**
* Return true if the document is in XMI version 1.x
*
* @param DOMDocument $d DOM document
*
* @return boolean
*/
static function isVersion1(DOMDocument $d)
{
$version = $d->getElementsByTagName('XMI')->item(0)->getAttribute('xmi.version');
if ($version=='')
$version = $d->getElementsByTagName('XMI')->item(0)->getAttribute('xmi:version');
return ($version<2);
}
}
?>

View File

@@ -0,0 +1,96 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" exclude-result-prefixes="uml xmi"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:uml="http://schema.omg.org/spec/UML/2.1.2"
xmlns:xmi="http://schema.omg.org/spec/XMI/2.1">
<!-- General templates used by the exporting system -->
<xsl:key name="getElementById" match="packagedElement" use="@xmi:id"/>
<xsl:key name="getRealizations" match="packagedElement[@xmi:type='uml:Realization']" use="@client"/>
<xsl:key name="getRealizingClasses" match="packagedElement[@xmi:type='uml:Realization']" use="@supplier"/>
<xsl:key name="getMetadata" match="/*[1]/*[name()='php:docblock']" use="@base_Element"/>
<xsl:key name="getSubclasses" match="packagedElement" use="generalization/@general"/>
<xsl:key name="getManifestation" match="manifestation" use="@supplier"/>
<xsl:param name="phpCreateFolder"/>
<xsl:param name="phpSaveToFile"/>
<xsl:param name="appName" />
<xsl:param name="genDate" />
<!-- Starting templates -->
<xsl:template match="/">
<xsl:for-each select="descendant::*">
<xsl:choose>
<xsl:when test="name()='uml:Model'">
<xsl:call-template name="top-container"/>
</xsl:when>
</xsl:choose>
</xsl:for-each>
</xsl:template>
<!-- Each implementation (documentation or code) must provide a "top-container" template -->
<xsl:template match="uml:Model">
<xsl:call-template name="top-container"/>
</xsl:template>
<!-- Library -->
<!-- Returns the package part of the context element (eg: PHP.UML) -->
<xsl:template name="getPackageNamePart">
<xsl:param name="context" select="."/>
<xsl:for-each select="$context/ancestor::packagedElement">
<xsl:value-of select="concat(@name, $packageDelimiter)"/>
</xsl:for-each>
</xsl:template>
<!-- Returns the filepath that leads to the context element, from the top container -->
<xsl:template name="getPackageFilePath">
<xsl:param name="context" />
<xsl:for-each select="$context/ancestor::packagedElement">
<xsl:value-of select="concat(@name, '/')"/>
</xsl:for-each>
</xsl:template>
<!-- Same as getPackageNamePart(), without the trailing delimiter -->
<xsl:template name="getNestingPackageName">
<xsl:param name="context" />
<xsl:variable name="packageNamePart">
<xsl:call-template name="getPackageNamePart">
<xsl:with-param name="context" select="$context" />
</xsl:call-template>
</xsl:variable>
<xsl:value-of select="substring($packageNamePart, 1, string-length($packageNamePart)-string-length($packageDelimiter))"/>
</xsl:template>
<xsl:template name="getPrefix">
<xsl:param name="context" select="."/>
<xsl:choose>
<xsl:when test="$context/@xmi:type='uml:Interface'">
<xsl:value-of select="$fileprefixInterface"/>
</xsl:when>
<xsl:when test="$context/@xmi:type='uml:DataType'">
<xsl:value-of select="$fileprefixDatatype"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$fileprefixClass"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="titleComment">
<xsl:value-of select="substring-before(concat(ownedComment/body/text()|ownedComment/@body, $cr), $cr)"/>
</xsl:template>
<xsl:template name="toLowerCase">
<xsl:param name="str"/>
<xsl:value-of select="translate($str, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')"/>
</xsl:template>
<xsl:template name="toUpperCase">
<xsl:param name="str"/>
<xsl:value-of select="translate($str, 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
</xsl:template>
</xsl:stylesheet>

View File

@@ -0,0 +1,339 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:uml="http://schema.omg.org/spec/UML/2.1" xmlns:xmi="http://schema.omg.org/spec/XMI/2.1"
xmlns:UML="http://www.omg.org/spec/UML/1.4" exclude-result-prefixes="uml UML">
<xsl:include href="common.xsl"/>
<xsl:key name="association1" match="UML:Association|UML:AssociationClass" use="UML:Association.connection/UML:AssociationEnd[1]/UML:AssociationEnd.participant/*/@xmi.idref" />
<xsl:key name="association2" match="UML:Association|UML:AssociationClass" use="UML:Association.connection/UML:AssociationEnd[2]/UML:AssociationEnd.participant/*/@xmi.idref" />
<xsl:key name="abstraction" match="UML:Abstraction" use="@xmi.id"/>
<xsl:key name="generalization" match="UML:Generalization[UML:Generalization.parent/UML:Class]" use="UML:Generalization.child/UML:Class/@xmi.idref" /><!-- argo/rationale -->
<xsl:key name="generalization2" match="UML:Generalization[not(UML:Generalization.parent/UML:Class)]" use="@child" /> <!--- umbrello-->
<xsl:key name="getTaggedValue" match="UML:TaggedValue[@tag='documentation']" use="@modelElement"/>
<xsl:param name="appName"/>
<xsl:param name="targetVersion" select="string('2.1')"/>
<xsl:output encoding="iso-8859-1" method="xml" indent="yes" />
<!-- XMI -->
<xsl:template match="/">
<xmi:XMI xmi:version="2.1" xmlns:uml="http://schema.omg.org/spec/UML/2.1" xmlns:xmi="http://schema.omg.org/spec/XMI/2.1">
<xsl:apply-templates select="XMI" />
</xmi:XMI>
</xsl:template>
<xsl:template match="XMI">
<xsl:apply-templates />
</xsl:template>
<xsl:template match="XMI.documentation">
<xmi:Documentation>
<xsl:attribute name="exporter"><xsl:value-of select="XMI.exporter"/><xsl:value-of select="concat('Conversion to XMI ',$targetVersion,' by ',$appName)"/></xsl:attribute>
<xsl:attribute name="exporterVersion"><xsl:value-of select="XMI.exporterVersion"/></xsl:attribute>
</xmi:Documentation>
</xsl:template>
<xsl:template match="XMI.content">
<xsl:apply-templates select="UML:Model"/>
</xsl:template>
<xsl:template match="XMI.extension">
<xmi:Extension>
<xsl:if test="@xmi.extender!=''"><xsl:attribute name="extender"><xsl:value-of select="@xmi.extender"/></xsl:attribute></xsl:if>
<xsl:copy-of select="*"/>
</xmi:Extension>
</xsl:template>
<!-- CONTAINERS -->
<xsl:template match="UML:Model">
<uml:Model xmi:type="uml:Model" name="{@name}" xmi:id="{@xmi.id}">
<xsl:if test="@visibility!=''"><xsl:attribute name="visibility"><xsl:value-of select="@visibility"/></xsl:attribute></xsl:if>
<xsl:call-template name="namespace-ownedElement"/>
</uml:Model>
</xsl:template>
<xsl:template match="UML:Package">
<packagedElement xmi:type="uml:Package" xmi:id="{@xmi.id}" name="{@name}">
<xsl:call-template name="namespace-ownedElement"/>
</packagedElement>
</xsl:template>
<xsl:template name="namespace-ownedElement">
<xsl:for-each select="UML:Namespace.ownedElement">
<xsl:apply-templates select="UML:Model"/>
<xsl:apply-templates select="UML:Package"/>
<xsl:apply-templates select="UML:UseCase"/>
<xsl:apply-templates select="UML:Actor"/>
<xsl:apply-templates select="UML:Class[@name!='']"/>
<xsl:apply-templates select="UML:Association"/>
<xsl:apply-templates select="UML:AssociationClass"/>
<xsl:apply-templates select="UML:Interface"/>
<xsl:apply-templates select="UML:Dependency"/>
<xsl:apply-templates select="UML:Stereotype"/>
<xsl:apply-templates select="UML:Abstraction"/>
<xsl:apply-templates select="UML:Artifact"/>
<xsl:apply-templates select="UML:DataType"/>
<xsl:apply-templates select="XMI.extension"/>
<!--xsl:call-template name="realization"/-->
</xsl:for-each>
<xsl:call-template name="comment"/>
<xsl:apply-templates select="XMI.extension"/>
</xsl:template>
<!-- ELEMENTS -->
<xsl:template match="UML:Actor">
<packagedElement xmi:type="uml:Actor" name="{@name}" xmi:id="{@xmi.id}" visibility="{@visibility}" isAbstract="{@isAbstract}"/>
</xsl:template>
<xsl:template match="UML:UseCase">
<packagedElement xmi:type="uml:UseCase" name="{@name}" xmi:id="{@xmi.id}" visibility="{@visibility}" isAbstract="{@isAbstract}"/>
</xsl:template>
<xsl:template match="UML:Class">
<xsl:call-template name="class"/>
</xsl:template>
<xsl:template name="class">
<xsl:variable name="hic" select="@xmi.id"/>
<packagedElement xmi:type="uml:Class" name="{@name}" xmi:id="{$hic}" visibility="{@visibility}" isAbstract="{@isAbstract}">
<xsl:for-each select="key('generalization',$hic)">
<generalization xmi:type="uml:Generalization" xmi:id="{@xmi.id}" general="{UML:Generalization.parent/UML:Class/@xmi.idref}"/>
</xsl:for-each>
<xsl:for-each select="key('generalization2',$hic)">
<generalization xmi:type="uml:Generalization" xmi:id="{@xmi.id}" general="{@parent}"/>
</xsl:for-each>
<xsl:for-each select="key('association2',$hic)/UML:Association.connection/UML:AssociationEnd[1]">
<ownedAttribute xmi:type="uml:Property" name="" association="{../../@xmi.id}" aggregation="{@aggregation}" xmi:id="{concat($hic,'_',../../@xmi.id)}">
<type xmi:idref="{UML:AssociationEnd.participant/*/@xmi.idref}" />
<lowerValue xmi:type="uml:LiteralString">
<xsl:attribute name="value"><xsl:call-template name="convInfinite"><xsl:with-param name="value" select="UML:AssociationEnd.multiplicity/UML:Multiplicity/UML:Multiplicity.range/UML:MultiplicityRange/@lower"/></xsl:call-template></xsl:attribute>
</lowerValue>
<upperValue xmi:type="uml:LiteralString">
<xsl:attribute name="value"><xsl:call-template name="convInfinite"><xsl:with-param name="value" select="UML:AssociationEnd.multiplicity/UML:Multiplicity/UML:Multiplicity.range/UML:MultiplicityRange/@upper"/></xsl:call-template></xsl:attribute>
</upperValue>
</ownedAttribute>
</xsl:for-each>
<xsl:for-each select="key('association1',$hic)/UML:Association.connection/UML:AssociationEnd[2]" >
<ownedAttribute xmi:type="uml:Property" name="" association="{../../@xmi.id}" aggregation="{@aggregation}" xmi:id="{concat($hic,'_',../../@xmi.id)}">
<type xmi:idref="{UML:AssociationEnd.participant/*/@xmi.idref}" />
<lowerValue xmi:type="uml:LiteralString">
<xsl:attribute name="value"><xsl:call-template name="convInfinite"><xsl:with-param name="value" select="UML:AssociationEnd.multiplicity/UML:Multiplicity/UML:Multiplicity.range/UML:MultiplicityRange/@lower"/></xsl:call-template></xsl:attribute>
</lowerValue>
<upperValue xmi:type="uml:LiteralString">
<xsl:attribute name="value"><xsl:call-template name="convInfinite"><xsl:with-param name="value" select="UML:AssociationEnd.multiplicity/UML:Multiplicity/UML:Multiplicity.range/UML:MultiplicityRange/@upper"/></xsl:call-template></xsl:attribute>
</upperValue>
</ownedAttribute>
</xsl:for-each>
<xsl:apply-templates select="UML:Classifier.feature/UML:Attribute"/>
<xsl:apply-templates select="UML:Classifier.feature/UML:Operation"/>
<xsl:call-template name="comment"/>
</packagedElement>
</xsl:template>
<xsl:template match="UML:Attribute">
<ownedAttribute xmi:type="uml:Property" name="{@name}" xmi:id="{@xmi.id}" visibility="{@visibility}" >
<xsl:if test="@isAbstract"><xsl:attribute name="isAbstract">true</xsl:attribute></xsl:if>
<xsl:if test="@isStatic or @ownerScope='classifier'"><xsl:attribute name="isStatic">true</xsl:attribute></xsl:if>
<xsl:if test="@isReadOnly or @changeability='frozen'"><xsl:attribute name="isReadOnly">true</xsl:attribute></xsl:if>
<type xmi:idref="{(UML:StructuralFeature.type/UML:DataType/@xmi.idref)|@type}" />
<xsl:if test="UML:Attribute.initialValue">
<xsl:for-each select="UML:Attribute.initialValue">
<defaultValue xmi:type="uml:LiteralString" xmi:id="{UML:Expression/@xmi.id}" value="{UML:Expression/@body}" />
</xsl:for-each>
</xsl:if>
<xsl:if test="@initialValue!=''"> <!-- umbrello-->
<defaultValue xmi:type="uml:LiteralString" xmi:id="{concat(@xmi.id,'dv')}" value="{@initialValue}"/>
</xsl:if>
<xsl:call-template name="comment"/>
<xsl:apply-templates select="XMI.extension"/>
</ownedAttribute>
</xsl:template>
<xsl:template match="UML:Operation">
<ownedOperation xmi:type="uml:Operation" name="{@name}" xmi:id="{@xmi.id}" visibility="{@visibility}" isAbstract="{@isAbstract}">
<xsl:if test="@isStatic or @ownerScope='classifier'"><xsl:attribute name="isStatic">true</xsl:attribute></xsl:if>
<xsl:if test="@isRoot"><xsl:attribute name="isRoot">true</xsl:attribute></xsl:if>
<xsl:for-each select="UML:BehavioralFeature.parameter/UML:Parameter">
<ownedParameter name="{@name}" xmi:id="{@xmi.id}" direction="{@kind}">
<type xmi:idref="{(UML:Parameter.type/UML:DataType/@xmi.idref)|@type}" />
<xsl:for-each select="UML:Parameter.defaultValue">
<defaultValue xmi:type="uml:LiteralString" xmi:id="{UML:Expression/@xmi.id}" value="{UML:Expression/@body}"/>
</xsl:for-each>
<xsl:if test="@value!=''"> <!-- umbrello-->
<defaultValue xmi:type="uml:LiteralString" xmi:id="{concat(@xmi.id,'dv')}" value="{@value}"/>
</xsl:if>
<xsl:call-template name="comment"/>
</ownedParameter>
</xsl:for-each>
<xsl:call-template name="comment"/>
<xsl:apply-templates select="XMI.extension"/>
</ownedOperation>
</xsl:template>
<xsl:template match="UML:DataType">
<packagedElement xmi:type="uml:DataType" name="{@name}" xmi:id="{@xmi.id}"/>
</xsl:template>
<xsl:template match="UML:Interface">
<packagedElement xmi:type="uml:Interface" name="{@name}" xmi:id="{@xmi.id}" visibility="{@visibility}" isAbstract="{@isAbstract}">
<xsl:apply-templates select="UML:Classifier.feature/UML:Operation"/>
<xsl:call-template name="comment"/>
<xsl:apply-templates select="XMI.extension"/>
</packagedElement>
</xsl:template>
<xsl:template match="UML:Artifact">
<packagedElement xmi:type="uml:Artifact" xmi:id="{@xmi.id}" name="{@name}" stereotype="{UML:ModelElement.stereotype/UML:Stereotype/@xmi.idref}"/>
</xsl:template>
<xsl:template match="UML:Stereotype">
<packagedElement xmi:type="uml:Stereotype" xmi:id="{@xmi.id}" name="{@name}" isAbstract="{@isAbstract}"/>
</xsl:template>
<!-- STRUCTURAL ELEMENTS -->
<xsl:template match="UML:Dependency">
<xsl:choose>
<xsl:when test="UML:Dependency.client">
<packagedElement xmi:type="uml:Dependency" xmi:id="{@xmi.id}" client="{UML:Dependency.client/UML:Class/@xmi.idref}" supplier="{UML:Dependency.supplier/UML:Class/@xmi.idref}">
<xsl:if test="@name!=''">
<xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>
</xsl:if>
<xsl:apply-templates select="UML:Classifier.feature/UML:Operation"/>
</packagedElement>
</xsl:when>
<xsl:when test="@client!=''">
<packagedElement xmi:type="uml:Dependency" xmi:id="{@xmi.id}" client="{@client}" supplier="{@supplier}" visibility="{@visibility}">
<xsl:if test="@name!=''">
<xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>
</xsl:if>
</packagedElement>
</xsl:when>
</xsl:choose>
</xsl:template>
<xsl:template match="UML:Association">
<xsl:call-template name="association"/>
</xsl:template>
<xsl:template match="UML:AssociationClass">
<xsl:call-template name="class"/>
<xsl:call-template name="association"><xsl:with-param name="type">AC</xsl:with-param></xsl:call-template>
</xsl:template>
<xsl:template match="UML:Generalization"/>
<xsl:template match="UML:Abstraction">
<xsl:choose>
<xsl:when test="@client!=''">
<packagedElement xmi:type="uml:Realization" xmi:id="{@xmi.id}" client="{@client}" supplier="{@supplier}" realizingClassifier="{@supplier}" />
</xsl:when>
<xsl:when test="UML:Dependency.supplier">
<xsl:variable name="supplier" select="UML:Dependency.supplier/*/@xmi.idref"/>
<packagedElement xmi:type="uml:Realization" xmi:id="{@xmi.id}" client="{UML:Dependency.client/UML:Class/@xmi.idref}" supplier="{$supplier}" realizingClassifier="{$supplier}" />
</xsl:when>
</xsl:choose>
</xsl:template>
<xsl:template name="convInfinite">
<xsl:param name="value"/>
<xsl:choose>
<xsl:when test="$value='-1'">*</xsl:when>
<xsl:otherwise><xsl:value-of select="$value"/></xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="association">
<xsl:param name="type" select="''" />
<packagedElement xmi:type="uml:Association" xmi:id="{concat($type,@xmi.id)}">
<xsl:choose>
<xsl:when test="$type!='AC'">
<xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="name"></xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:variable name="class_far1" select="UML:Association.connection/UML:AssociationEnd[1]/UML:AssociationEnd.participant/*/@xmi.idref"/>
<memberEnd xmi:idref="{concat($class_far1,'_',@xmi.id)}" />
<xsl:variable name="class_far2" select="UML:Association.connection/UML:AssociationEnd[2]/UML:AssociationEnd.participant/*/@xmi.idref"/>
<memberEnd xmi:idref="{concat($class_far2,'_',@xmi.id)}" />
</packagedElement>
<xsl:if test="$type='AC'">
<packagedElement xmi:type="uml:AssociationClass" xmi:id="{concat('AAC',@xmi.id)}">
<memberEnd xmi:idref="{concat($type,@xmi.id)}"/>
<memberEnd xmi:idref="{@xmi.id}"/>
</packagedElement>
</xsl:if>
</xsl:template>
<!-- COMMENTS -->
<xsl:template match="UML:Comment">
<xsl:call-template name="comment-body">
<xsl:with-param name="id" select="@xmi.id"/>
<xsl:with-param name="text" select="@body"/>
</xsl:call-template>
</xsl:template>
<xsl:template match="UML:ModelElement.taggedValue/UML:TaggedValue">
<xsl:call-template name="comment-body">
<xsl:with-param name="id" select="@xmi.id"/>
<xsl:with-param name="text" select="UML:TaggedValue.dataValue/text()"/>
</xsl:call-template>
</xsl:template>
<xsl:template name="comment">
<xsl:apply-templates select="UML:Comment"/>
<xsl:apply-templates select="UML:ModelElement.taggedValue/UML:TaggedValue"/><!-- argo -->
<xsl:for-each select="key('getTaggedValue', @xmi.id)"> <!-- rationale -->
<xsl:call-template name="comment-body">
<xsl:with-param name="id" select="concat(@xmi.id,'comment')"/>
<xsl:with-param name="text" select="concat(@value, UML:TaggedValue.value/text())"/>
</xsl:call-template>
</xsl:for-each>
<xsl:call-template name="comment-body"><!-- umbrello-->
<xsl:with-param name="id" select="concat(@xmi.id,'comment')"/>
<xsl:with-param name="text" select="@comment"/>
</xsl:call-template>
</xsl:template>
<xsl:template name="comment-body">
<xsl:param name="id" value="id"/>
<xsl:param name="text" value="text"/>
<xsl:if test="$text!=''">
<ownedComment xmi:type="uml:Comment" xmi:id="{$id}">
<body><xsl:value-of select="$text"/></body>
</ownedComment>
</xsl:if>
</xsl:template>
</xsl:stylesheet>