diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | bd9e6617827818fd043452c08c606f07b78014a0 (patch) | |
tree | 425bb4c3168f9c02f10150f235d2cb998dcc6108 /umbrello/umbrello/docgenerators | |
download | tdesdk-bd9e6617827818fd043452c08c606f07b78014a0.tar.gz tdesdk-bd9e6617827818fd043452c08c606f07b78014a0.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdesdk@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'umbrello/umbrello/docgenerators')
-rw-r--r-- | umbrello/umbrello/docgenerators/Makefile.am | 21 | ||||
-rw-r--r-- | umbrello/umbrello/docgenerators/common.ent | 19 | ||||
-rw-r--r-- | umbrello/umbrello/docgenerators/docbook2xhtml.xsl | 7 | ||||
-rw-r--r-- | umbrello/umbrello/docgenerators/docbookgenerator.cpp | 145 | ||||
-rw-r--r-- | umbrello/umbrello/docgenerators/docbookgenerator.h | 78 | ||||
-rw-r--r-- | umbrello/umbrello/docgenerators/main.cpp | 94 | ||||
-rw-r--r-- | umbrello/umbrello/docgenerators/xhtmlgenerator.cpp | 171 | ||||
-rw-r--r-- | umbrello/umbrello/docgenerators/xhtmlgenerator.h | 104 | ||||
-rw-r--r-- | umbrello/umbrello/docgenerators/xmi.css | 170 | ||||
-rw-r--r-- | umbrello/umbrello/docgenerators/xmi2docbook.sh | 9 | ||||
-rw-r--r-- | umbrello/umbrello/docgenerators/xmi2docbook.xsl | 998 |
11 files changed, 1816 insertions, 0 deletions
diff --git a/umbrello/umbrello/docgenerators/Makefile.am b/umbrello/umbrello/docgenerators/Makefile.am new file mode 100644 index 00000000..47087c4c --- /dev/null +++ b/umbrello/umbrello/docgenerators/Makefile.am @@ -0,0 +1,21 @@ +INCLUDES = -I$(srcdir)/.. -I$(top_srcdir)/umbrello/docgenerators -I../../../umbrello/umbrello $(LIBXML_CFLAGS) $(all_includes) +METASOURCES = AUTO +bin_PROGRAMS = umbodoc + +AM_LDFLAGS = $(all_libraries) +umbodoc_COMPILE_FIRST = version.h +umbodoc_SOURCES = main.cpp +umbodoc_LDADD = $(LIB_KDECORE) $(LIBXSLT_LIBS) $(LIBXML_LIBS) +noinst_LTLIBRARIES = libdocgenerators.la +noinst_HEADERS = docbookgenerator.h version.h +libdocgenerators_la_SOURCES = docbookgenerator.h docbookgenerator.cpp xhtmlgenerator.cpp +libdocgenerators_la_LIBADD = $(LIB_KDECORE) $(LIBXSLT_LIBS) $(LIBXML_LIBS) + +appdir=$(kde_datadir)/umbrello +app_DATA = xmi2docbook.xsl docbook2xhtml.xsl xmi.css common.ent + +version.h: $(top_srcdir)/umbrello/VERSION + printf "#undef UMBRELLO_VERSION\n#define UMBRELLO_VERSION \"`cat $(top_srcdir)/umbrello/VERSION`\"\n" > version.h + +CLEANFILES = version.h + diff --git a/umbrello/umbrello/docgenerators/common.ent b/umbrello/umbrello/docgenerators/common.ent new file mode 100644 index 00000000..af88fd38 --- /dev/null +++ b/umbrello/umbrello/docgenerators/common.ent @@ -0,0 +1,19 @@ + + <!ENTITY title1 "Software Specifications" > + <!ENTITY title2 "" > + <!ENTITY actor "Actor:"> + <!ENTITY usecase "Use Cases:"> + <!ENTITY classes "Classes:"> + <!ENTITY back "Back"> + <!ENTITY packagename "Package Name:"> + <!ENTITY classname "Class Name:"> + <!ENTITY yes "yes"> + <!ENTITY no "no"> + <!ENTITY attributes "Attributes:"> + <!ENTITY metodes "Methods:"> + <!ENTITY parameters "Parameters:"> + + + + + diff --git a/umbrello/umbrello/docgenerators/docbook2xhtml.xsl b/umbrello/umbrello/docgenerators/docbook2xhtml.xsl new file mode 100644 index 00000000..8b0e5b11 --- /dev/null +++ b/umbrello/umbrello/docgenerators/docbook2xhtml.xsl @@ -0,0 +1,7 @@ +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + version='1.0'> + <!--xsl:import href="docbook-xsl-1.70.1/xhtml/docbook.xsl"/--> + <xsl:import href="http://docbook.sourceforge.net/release/xsl/snapshot/html/docbook.xsl"/> + <xsl:param name="html.stylesheet">xmi.css</xsl:param> +</xsl:stylesheet> + diff --git a/umbrello/umbrello/docgenerators/docbookgenerator.cpp b/umbrello/umbrello/docgenerators/docbookgenerator.cpp new file mode 100644 index 00000000..9907d6f9 --- /dev/null +++ b/umbrello/umbrello/docgenerators/docbookgenerator.cpp @@ -0,0 +1,145 @@ +/*************************************************************************** + * docbookgenerator.cpp - description * + * ------------------- * + * copyright : (C) 2006 by Gael de Chalendar (aka Kleag) * + * (C) 2006 Umbrello UML Modeller Authors <uml-devel@uml.sf.net> * + *************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "docbookgenerator.h" + +#include <libxml/xmlmemory.h> +#include <libxml/debugXML.h> +#include <libxml/HTMLtree.h> +#include <libxml/xmlIO.h> +#include <libxml/xinclude.h> +#include <libxml/catalog.h> +#include <libxslt/xslt.h> +#include <libxslt/xsltInternals.h> +#include <libxslt/transform.h> +#include <libxslt/xsltutils.h> + +#include <kdebug.h> +#include <klocale.h> +#include <ktempfile.h> +#include <kmessagebox.h> +#include <kio/job.h> +#include <kstandarddirs.h> +#include <qfile.h> +#include <qregexp.h> +#include <qtextstream.h> + +#include "uml.h" +#include "umldoc.h" +#include "umlviewimageexportermodel.h" + +extern int xmlLoadExtDtdDefaultValue; + +DocbookGenerator::DocbookGenerator() +{ +} + +DocbookGenerator::~DocbookGenerator() {} + + +bool DocbookGenerator::generateDocbookForProject() +{ + UMLApp *app = UMLApp::app(); + UMLDoc* umlDoc = app->getDocument(); + KURL url = umlDoc->URL(); + QString fileName = url.fileName(); + fileName.replace(QRegExp(".xmi$"),""); + url.setFileName(fileName); + kDebug() << "Exporting to directory: " << url << endl; + generateDocbookForProjectInto(url); + return true; +} + +KIO::Job* DocbookGenerator::generateDocbookForProjectInto(const KURL& destDir) +{ + UMLApp* app = UMLApp::app(); + UMLDoc* umlDoc = app->getDocument(); + + // export all views + umlDoc->writeToStatusBar(i18n("Exporting all views...")); + QStringList errors = UMLViewImageExporterModel().exportAllViews( + UMLViewImageExporterModel::mimeTypeToImageType("image/png"), + destDir, false); + if (!errors.empty()) + { +#if KDE_IS_VERSION(3,4,0) + KMessageBox::errorList(app, i18n("Some errors happened when exporting the images:"), errors); +#else + QString errorsCaption; + for (QStringList::Iterator it = errors.begin(); it != errors.end(); ++it) { + errorsCaption += "\n" + *it; + } + KMessageBox::error(app, i18n("Some errors happened when exporting the images:") + errorsCaption); +#endif + return 0; + } + + //write the XMI model in an in-memory char* string + QString xmi; + QTextOStream xmiStream(&xmi); + + KTempFile tmpfile; // we need this tmp file if we are writing to a remote file + + QFile file; + file.setName( tmpfile.name() ); + + // lets open the file for writing + if( !file.open( IO_WriteOnly ) ) { + KMessageBox::error(0, i18n("There was a problem saving file: %1").arg(tmpfile.name()), i18n("Save Error")); + return false; + } + umlDoc->saveToXMI(file); // save the xmi stuff to it + file.close(); + tmpfile.close(); + + xsltStylesheetPtr cur = NULL; + xmlDocPtr doc, res; + + const char *params[16 + 1]; + int nbparams = 0; + params[nbparams] = NULL; + + QString xsltFile(KGlobal::dirs()->findResource("appdata","xmi2docbook.xsl")); + + xmlSubstituteEntitiesDefault(1); + xmlLoadExtDtdDefaultValue = 1; + cur = xsltParseStylesheetFile((const xmlChar *)xsltFile.latin1()); + doc = xmlParseFile((const char*)(tmpfile.name().utf8())); + res = xsltApplyStylesheet(cur, doc, params); + + KTempFile tmpDocBook; + tmpDocBook.setAutoDelete(false); + + xsltSaveResultToFile(tmpDocBook.fstream(), res, cur); + xsltFreeStylesheet(cur); + xmlFreeDoc(res); + xmlFreeDoc(doc); + + xsltCleanupGlobals(); + xmlCleanupParser(); + + KURL url = umlDoc->URL(); + QString fileName = url.fileName(); + fileName.replace(QRegExp(".xmi$"),".docbook"); + url.setPath(destDir.path()); + url.addPath(fileName); + kDebug() << "Copying result to: " << url << endl; + KIO::Job* job = KIO::file_copy(tmpDocBook.file()->name(),url,-1,true,false,false); + job->setAutoErrorHandlingEnabled(true); + + return job; +} + + +#include "docbookgenerator.moc" diff --git a/umbrello/umbrello/docgenerators/docbookgenerator.h b/umbrello/umbrello/docgenerators/docbookgenerator.h new file mode 100644 index 00000000..775a7383 --- /dev/null +++ b/umbrello/umbrello/docgenerators/docbookgenerator.h @@ -0,0 +1,78 @@ +/*************************************************************************** + docbookgenerator.h - description + ------------------- + begin : THu Jun 22 2006 + copyright : (C) 2006 by Gael de Chalendar (aka Kleag) + email : kleag@free.fr + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef DOCBOOKGENERATOR_H +#define DOCBOOKGENERATOR_H + +#include <kurl.h> +#include <qobject.h> + +class UMLDoc; + +namespace KIO +{ + class Job; +} + +/** + * class DocbookGenerator is a documentation generator for UML documents. + * It uses libxslt to convert the XMI generated by UMLDoc::saveToXMI through + * the XSLT file stored in resources. + * + * @todo Add configure checks for libxml2 and libxslt and use conditional + * compilation of this library and its callers + * @todo allow to specify the destination and ensure that it works with distant + * ones + */ +class DocbookGenerator : public QObject +{ + Q_OBJECT + public: + + /** + * Constructor + */ + DocbookGenerator(); + + /** + * Empty Destructor + */ + virtual ~DocbookGenerator(); + + /** + * Exports the current model to docbook in a directory named as the model + * with the .xmi suffix removed. The docbook file will have the same name + * with the .docbook suffix. Figures will be named as the corresponding + * diagrams in the GUI + * @todo change file naming to avoid paths with spaces or non-ASCII chars + * @todo better handling of error conditions + * @return true if saving is successful and false otherwise. + */ + bool generateDocbookForProject(); + + /** + * Exports the current model to docbook in the given directory + * @param destDir the directory where the docbook file and the figures will + * be written + * @todo better handling of error conditions + * @return true if saving is successful and false otherwise. + */ + KIO::Job* generateDocbookForProjectInto(const KURL& destDir); + +}; + +#endif // DOCBOOKGENERATOR_H diff --git a/umbrello/umbrello/docgenerators/main.cpp b/umbrello/umbrello/docgenerators/main.cpp new file mode 100644 index 00000000..d4b6fc4e --- /dev/null +++ b/umbrello/umbrello/docgenerators/main.cpp @@ -0,0 +1,94 @@ +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * copyright (C) 2002-2006 * + * Umbrello UML Modeller Authors <uml-devel@uml.sf.net> * + ***************************************************************************/ + +#include <unistd.h> + +#include <libxml/xmlmemory.h> +#include <libxml/debugXML.h> +#include <libxml/HTMLtree.h> +#include <libxml/xmlIO.h> +#include <libxml/DOCBparser.h> +#include <libxml/xinclude.h> +#include <libxml/catalog.h> +#include <libxslt/xslt.h> +#include <libxslt/xsltInternals.h> +#include <libxslt/transform.h> +#include <libxslt/xsltutils.h> + +// kde includes +#include <kaboutdata.h> +#include <kapplication.h> +#include <kcmdlineargs.h> +#include <kconfig.h> +#include <klocale.h> +#include <ktip.h> +#include <kdebug.h> +#include <kwin.h> + +#include "version.h" + +extern int xmlLoadExtDtdDefaultValue; + +static const char description[] = + I18N_NOOP("Umbrello UML Modeller autonomous code generator"); +// INSERT A DESCRIPTION FOR YOUR APPLICATION HERE + + +static KCmdLineOptions options[] = +{ + { "+[File]", I18N_NOOP("File to transform"), 0 }, + { "xslt <url>", I18N_NOOP("The XSLT file to use"), 0}, + // INSERT YOUR COMMANDLINE OPTIONS HERE + KCmdLineLastOption +}; + +int main(int argc, char *argv[]) +{ + xsltStylesheetPtr cur = NULL; + xmlDocPtr doc, res; + + const char *params[16 + 1]; + int nbparams = 0; + params[nbparams] = NULL; + + KAboutData aboutData( "umbodoc", I18N_NOOP("Umbrello UML Modeller autonomous code generator"), + UMBRELLO_VERSION, description, KAboutData::License_GPL, + I18N_NOOP("(c) 2006 Gael de Chalendar (aka Kleag), (c) 2002-2006 Umbrello UML Modeller Authors"), 0, + "http://uml.sf.net/"); + aboutData.addAuthor("Gael de Chalendar (aka Kleag)",0, "kleag@free.fr"); + aboutData.addAuthor(I18N_NOOP("Umbrello UML Modeller Authors"), 0, "uml-devel@lists.sourceforge.net"); + KCmdLineArgs::init( argc, argv, &aboutData ); + KCmdLineArgs::addCmdLineOptions( options ); // Add our own options. + + KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); + + QCStringList xsltOpt = args->getOptionList("xslt"); + if (xsltOpt.size() > 0) + { + QString xsltFile(xsltOpt.last()); + + xmlSubstituteEntitiesDefault(1); + xmlLoadExtDtdDefaultValue = 1; + cur = xsltParseStylesheetFile((const xmlChar *)xsltFile.latin1()); + doc = xmlParseFile(args->url( 0 ).url().latin1()); + res = xsltApplyStylesheet(cur, doc, params); + xsltSaveResultToFile(stdout, res, cur); + + xsltFreeStylesheet(cur); + xmlFreeDoc(res); + xmlFreeDoc(doc); + + xsltCleanupGlobals(); + xmlCleanupParser(); + } + return(0); +} + diff --git a/umbrello/umbrello/docgenerators/xhtmlgenerator.cpp b/umbrello/umbrello/docgenerators/xhtmlgenerator.cpp new file mode 100644 index 00000000..5da1ae75 --- /dev/null +++ b/umbrello/umbrello/docgenerators/xhtmlgenerator.cpp @@ -0,0 +1,171 @@ +/*************************************************************************** + * xhtmlgenerator.cpp - description * + * ------------------- * + * copyright : (C) 2006 by Gael de Chalendar (aka Kleag) * + * (C) 2006 Umbrello UML Modeller Authors <uml-devel@uml.sf.net> * + *************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "xhtmlgenerator.h" + +#include <libxml/xmlmemory.h> +#include <libxml/debugXML.h> +#include <libxml/HTMLtree.h> +#include <libxml/xmlIO.h> +#include <libxml/xinclude.h> +#include <libxml/catalog.h> +#include <libxslt/xslt.h> +#include <libxslt/xsltInternals.h> +#include <libxslt/transform.h> +#include <libxslt/xsltutils.h> + +#include <kdebug.h> +#include <klocale.h> +#include <ktempfile.h> +#include <kmessagebox.h> +#include <kio/job.h> +#include <kstandarddirs.h> +#include <qfile.h> +#include <qregexp.h> +#include <qtextstream.h> + +#include "uml.h" +#include "umldoc.h" +#include "umlviewimageexportermodel.h" +#include "docbookgenerator.h" + +extern int xmlLoadExtDtdDefaultValue; + +XhtmlGenerator::XhtmlGenerator() +{ +} + +XhtmlGenerator::~XhtmlGenerator() {} + + +bool XhtmlGenerator::generateXhtmlForProject() +{ + UMLApp *app = UMLApp::app(); + UMLDoc* umlDoc = app->getDocument(); + KURL url = umlDoc->URL(); + QString fileName = url.fileName(); + fileName.replace(QRegExp(".xmi$"),""); + url.setFileName(fileName); + kDebug() << "Exporting to directory: " << url << endl; + return generateXhtmlForProjectInto(url); +} + +bool XhtmlGenerator::generateXhtmlForProjectInto(const KURL& destDir) +{ + kDebug() << "First convert to docbook" << endl; + m_destDir = destDir; +// KURL url(QString("file://")+m_tmpDir.name()); + KIO::Job* docbookJob = DocbookGenerator().generateDocbookForProjectInto(destDir); + if (docbookJob == 0) + { + return false; + } + kDebug() << "Connecting..." << endl; + connect(docbookJob, SIGNAL(result( KIO::Job * )), this, SLOT(slotDocbookToXhtml( KIO::Job *))); + return true; +} + +void XhtmlGenerator::slotDocbookToXhtml(KIO::Job * docbookJob) +{ + kDebug() << "Now convert docbook to html..." << endl; + if ( docbookJob->error() ) + { + docbookJob->showErrorDialog( 0L ); + return; + } + + UMLApp* app = UMLApp::app(); + UMLDoc* umlDoc = app->getDocument(); + + const KURL& url = umlDoc->URL(); + QString docbookName = url.fileName(); + docbookName.replace(QRegExp(".xmi$"),".docbook"); +// KURL docbookUrl(QString("file://")+m_tmpDir.name()); + KURL docbookUrl = m_destDir; + docbookUrl.addPath(docbookName); + + xsltStylesheetPtr cur = NULL; + xmlDocPtr doc, res; + + const char *params[16 + 1]; + int nbparams = 0; + params[nbparams] = NULL; + + QString xsltFileName(KGlobal::dirs()->findResource("appdata","docbook2xhtml.xsl")); + kDebug() << "XSLT file is'"<<xsltFileName<<"'" << endl; + QFile xsltFile(xsltFileName); + xsltFile.open(IO_ReadOnly); + QString xslt = xsltFile.readAll(); + kDebug() << "XSLT is'"<<xslt<<"'" << endl; + xsltFile.close(); + + QString localXsl = KGlobal::dirs()->findResource("data","ksgmltools2/docbook/xsl/html/docbook.xsl"); + kDebug() << "Local xsl is'"<<localXsl<<"'" << endl; + if (!localXsl.isEmpty()) + { + localXsl = QString("href=\"file://") + localXsl + "\""; + xslt.replace(QRegExp("href=\"http://[^\"]*\""),localXsl); + } + KTempFile tmpXsl; + *tmpXsl.textStream() << xslt; + tmpXsl.file()->close(); + + + xmlSubstituteEntitiesDefault(1); + xmlLoadExtDtdDefaultValue = 1; + kDebug() << "Parsing stylesheet " << tmpXsl.name() << endl; + cur = xsltParseStylesheetFile((const xmlChar *)tmpXsl.name().latin1()); + kDebug() << "Parsing file " << docbookUrl.path() << endl; + doc = xmlParseFile((const char*)(docbookUrl.path().utf8())); + kDebug() << "Applying stylesheet " << endl; + res = xsltApplyStylesheet(cur, doc, params); + + KTempFile tmpXhtml; + tmpXhtml.setAutoDelete(false); + + kDebug() << "Writing HTML result to temp file: " << tmpXhtml.file()->name() << endl; + xsltSaveResultToFile(tmpXhtml.fstream(), res, cur); + + xsltFreeStylesheet(cur); + xmlFreeDoc(res); + xmlFreeDoc(doc); + + xsltCleanupGlobals(); + xmlCleanupParser(); + + QString xhtmlName = url.fileName(); + xhtmlName.replace(QRegExp(".xmi$"),".html"); + KURL xhtmlUrl = m_destDir; + xhtmlUrl.addPath(xhtmlName); + + kDebug() << "Copying HTML result to: " << xhtmlUrl << endl; + KIO::Job* job = KIO::file_copy(tmpXhtml.file()->name(),xhtmlUrl,-1,true,false,false); + job->setAutoErrorHandlingEnabled(true); + connect (job, SIGNAL(result( KIO::Job* )), this, SLOT(slotHtmlCopyFinished( KIO::Job* ))); + + QString cssFileName(KGlobal::dirs()->findResource("appdata","xmi.css")); + kDebug() << "CSS file is'"<<cssFileName<<"'" << endl; + KURL cssUrl = m_destDir; + cssUrl.addPath("xmi.css"); + KIO::Job* cssJob = KIO::file_copy(cssFileName,cssUrl,-1,true,false,false); + cssJob->setAutoErrorHandlingEnabled(true); +} + +void XhtmlGenerator::slotHtmlCopyFinished( KIO::Job* ) +{ + kDebug() << "HTML copy finished: emiting finished" << endl; + emit(finished()); +} + +#include "xhtmlgenerator.moc" diff --git a/umbrello/umbrello/docgenerators/xhtmlgenerator.h b/umbrello/umbrello/docgenerators/xhtmlgenerator.h new file mode 100644 index 00000000..46402382 --- /dev/null +++ b/umbrello/umbrello/docgenerators/xhtmlgenerator.h @@ -0,0 +1,104 @@ +/*************************************************************************** + xhtmlgenerator.h - description + ------------------- + begin : Sat Jun 24 2006 + copyright : (C) 2006 by Gael de Chalendar (aka Kleag) + email : kleag@free.fr + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef XHTMLGENERATOR_H +#define XHTMLGENERATOR_H + +#include <kurl.h> +#include <ktempdir.h> +#include <qobject.h> + +namespace KIO +{ + class Job; +} + +/** + * class XhtmlGenerator is a documentation generator for UML documents. + * It uses first @ref DocbookGenerator to convert the XMI generated by + * UMLDoc::saveToXMI to docbook and next libxslt through + * the XSLT file stored in resources to convert the docbook file to XHTML. + * The latter uses the XSLT available on the Web at + * http://docbook.sourceforge.net/release/xsl/snapshot/html/docbook.xsl + * + * @todo allow to specify the destination and ensure that it works with distant + * ones + */ +class XhtmlGenerator : public QObject +{ + Q_OBJECT + public: + + /** + * Constructor + */ + XhtmlGenerator(); + + /** + * Empty Destructor + */ + virtual ~XhtmlGenerator(); + + /** + * Exports the current model to XHTML in a directory named as the model + * with the .xmi suffix removed. The XHTML file will have the same name + * with the .html suffix. Figures will be named as the corresponding + * diagrams in the GUI + * @todo change file naming to avoid paths with spaces or non-ASCII chars + * @todo better handling of error conditions + * @return true if saving is successful and false otherwise. + */ + bool generateXhtmlForProject(); + + /** + * Exports the current model to XHTML in the given directory + * @param destDir the directory where the XHTML file and the figures will + * be written + * @todo better handling of error conditions + * @return true if saving is successful and false otherwise. + */ + bool generateXhtmlForProjectInto(const KURL& destDir); + + signals: + + /** Emited when the documentation generation is finished */ + void finished(); + + protected slots: + + /** This slot is triggerd when the first part, xmi to docbook, is + * finished + * @param docbookJob the job copying the docbook file to its destination. + * Used only for error reporting + */ + void slotDocbookToXhtml(KIO::Job * docbookJob); + + /** Triggered when the copying of the HTML result file is finished. Emits + * the signal finished(). + */ + void slotHtmlCopyFinished( KIO::Job* ); + + private: + + /** The destination directory where the final documentation will be + * written. + */ + KURL m_destDir; +// KTempDir m_tmpDir; +}; + +#endif // XHTMLGENERATOR_H diff --git a/umbrello/umbrello/docgenerators/xmi.css b/umbrello/umbrello/docgenerators/xmi.css new file mode 100644 index 00000000..0cb67fea --- /dev/null +++ b/umbrello/umbrello/docgenerators/xmi.css @@ -0,0 +1,170 @@ +h1 {
+ font-family : Verdana, Arial, Helvetica;
+ font-size : 15pt;
+ font-weight : bold;
+ color : #333366;
+}
+
+.class-title {
+ background-color:#9999cc;
+ color : #ffffff;
+ font-family : Verdana, Helvetica;
+ font-size : 12pt;
+ font-weight : bold;
+}
+
+.class-name {
+ background-color:#ffffe0;
+ color : #6633cc;
+ font-family : Verdana, Helvetica;
+ font-size : 12pt;
+ font-weight : bold;
+}
+
+
+.interface-title {
+ background-color:#9999cc;
+ color : #ffffff;
+ font-family : Verdana, Helvetica;
+ font-size : 12pt;
+ font-weight : bold;
+}
+
+.interface-name {
+ background-color:#ffffe0;
+ color : #6633cc;
+ font-family : Verdana, Helvetica;
+ font-size : 12pt;
+ font-weight : bold;
+ font-style : italic;
+}
+
+.info-title {
+ background-color:#f0f0f0;
+ color : #888888;
+ font-family : Verdana, Helvetica;
+ font-size : 11pt;
+ font-weight : bold;
+ text-align : left;
+}
+
+.info {
+ background-color:#f0f0f0;
+ color : #000000;
+ font-family : Verdana, Helvetica;
+ font-size : 10pt;
+ text-align : left;
+}
+
+
+.class-feature {
+ background-color:#f0f0f0;
+ color : #848484;
+ font-family : Verdana, Helvetica;
+ font-size : 12pt;
+ font-weight : bold;
+ text-align : left;
+}
+
+.feature-heading {
+ color : #000099;
+ background-color:#ffffe0;
+ font-family : Verdana, Helvetica;
+ font-weight : bold;
+ font-size : 10pt;
+}
+
+.feature-detail {
+ color : #000000;
+ background-color:#ffffff;
+ font-family : Verdana, Helvetica;
+ font-size : 10pt;
+ text-align : left;
+}
+
+.comment {
+ color : #555555;
+ background-color:#ffffff;
+ font-family : Verdana, Helvetica;
+ font-size : 10pt;
+ text-align : left;
+ font-style : italic;
+}
+
+
+.datatype {
+ color : blue;
+}
+
+a.classifier:link {
+ color : blue;
+}
+
+a.classifier:visited {
+ color : blue;
+}
+
+a.interface:link {
+ color : blue;
+ font-style : italic;
+}
+
+a.interface:visited {
+ color : blue;
+ font-style : italic;
+}
+
+a.index-class:link {
+ font-family : Helvetica;
+ color : blue;
+ text-decoration : none;
+}
+
+a.index-class:visited {
+ font-family : Helvetica;
+ color : blue;
+ text-decoration : none;
+}
+
+a.index-interface:link {
+ color : blue;
+ font-style : italic;
+ text-decoration : none;
+}
+
+a.index-interface:visited {
+ color : blue;
+ font-style : italic;
+ text-decoration : none;
+}
+
+.index-title {
+ color : #000080;
+ font-family : Verdana, Helvetica;
+ font-size : 12pt;
+ font-weight : bold;
+}
+
+.parameter-heading {
+ color : #000099;
+ background-color: #f0f0f0;
+ font-family : Verdana, Helvetica;
+ font-weight : bold;
+ font-size : 10pt;
+}
+
+.property-name {
+ font-family : Verdana, Arial, Helvetica;
+ font-size : 8pt;
+ font-weight : bold;
+ color : Black;
+}
+
+.toc {
+color : #000099;
+background-color: #f0f0f0;
+font-family : Verdana, Helvetica;
+font-weight : normal;
+font-size : 10pt;
+}
+
diff --git a/umbrello/umbrello/docgenerators/xmi2docbook.sh b/umbrello/umbrello/docgenerators/xmi2docbook.sh new file mode 100644 index 00000000..32f46928 --- /dev/null +++ b/umbrello/umbrello/docgenerators/xmi2docbook.sh @@ -0,0 +1,9 @@ +#! /bin/bash + +echo Converting from XMI to docbook... +java -cp /usr/share/java/xalan-j2-2.6.0.jar org.apache.xalan.xslt.Process -xml -in $1.xmi -xsl /home/gael/Logiciels/kde3.5-svn/kdesdk/umbrello.withdocgen/umbrello/docgenerators/xmi2docbook.xsl -out $1.docbook + +echo Converting from docbook to XHTML... +java -cp /usr/share/java/xalan-j2-2.6.0.jar org.apache.xalan.xslt.Process -in $1.docbook -xsl /home/gael/Logiciels/kde3.5-svn/kdesdk/umbrello.withdocgen/umbrello/docgenerators/docbook2xhtml.xsl -out $1.html -html + +echo done. diff --git a/umbrello/umbrello/docgenerators/xmi2docbook.xsl b/umbrello/umbrello/docgenerators/xmi2docbook.xsl new file mode 100644 index 00000000..ff10aac5 --- /dev/null +++ b/umbrello/umbrello/docgenerators/xmi2docbook.xsl @@ -0,0 +1,998 @@ +<?xml version="1.0"?> +<!DOCTYPE article PUBLIC "-//OASIS//DTD Simplified DocBook XML V4.1.2.5//EN" + "http://www.oasis-open.org/docbook/xml/simple/4.1.2.5/sdocbook.dtd" + [ <!ENTITY % common SYSTEM "common.ent" > %common;] > + +<!-- + Title: umbrello-xmi-to-html.xsl + Purpose: An XSL stylesheet for converting Umbrello 1.4 XMI to HTML. + Based on xmi-to-html.xsl from Objects by Design. + + Copyright (C) 1999-2001, Objects by Design, Inc. All Rights Reserved. + Copyright (C) 2005, Oliver M. Kellogg <okellogg@users.sourceforge.net> + Copyright (C) 2006, Gaël de Chalendar (Kleag) <kleag@free.fr> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation. A copy of the license may be found at + http://www.gnu.org/licenses/gpl.html + + Version: June, 16 2006 + + xmlns="http://www.w3.org/1999/xhtml" +--> + +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + version="1.0" + xmlns:UML="http://schema.omg.org/spec/UML/1.3" + exclude-result-prefixes="UML"> + +<xsl:output method="xml" indent="yes" + doctype-system="http://www.oasis-open.org/docbook/xml/simple/4.1.2.5/sdocbook.dtd" + doctype-public="-//OASIS//DTD Simplified DocBook XML V4.1.2.5//EN" /> + +<xsl:key + name="classifier" + match="//UML:Class" + use="@xmi.id"/> + +<xsl:key + name="generalization" + match="//UML:Generalization" + use="@xmi.id"/> + +<xsl:key + name="abstraction" + match="//UML:Abstraction" + use="@xmi.id"/> + +<xsl:key + name="multiplicity" + match="//UML:Multiplicity" + use="@xmi.id"/> + + +<!-- Document Root --> +<xsl:template match="/"> + <article role="specification"> + <xsl:apply-templates select="//UML:Model" mode="title"/> + + <!-- Actors --> + <section id="actors"> + <title>Actors</title> + <xsl:apply-templates select="//UML:Actor"/> + </section> + + <!-- Use Cases --> + <section id="usecases"> + <title>Use Cases</title> + <xsl:apply-templates select="//UML:UseCase"/> + </section> + + <!-- Interfaces --> + <section id="interfaces"> + <title>Interfaces</title> + <xsl:apply-templates select="//UML:Interface"/> + </section> + + <!-- Classes --> + <section id="classes"> + <title>Classes</title> + <xsl:apply-templates select="//UML:Class"/> + </section> + <!-- Diagrams --> + <section id="diagrams"> + <title>Diagrams</title> + <xsl:apply-templates select="//diagrams/diagram"/> + </section> + </article> + +</xsl:template> + + +<!-- Window Title --> +<xsl:template match="UML:Model" mode="title"> + <title> + <!-- Name of the model --> + <xsl:value-of select="@name"/> + </title> +</xsl:template> + + +<!-- Actor --> +<xsl:template match="UML:Actor"> + <xsl:variable name="element_name" select="@name"/> + <xsl:variable name="xmi_id" select="@xmi.id" /> + <xsl:variable name="comment" select="@comment" /> + + <section> + <title><xsl:value-of select="$element_name"/></title> + + <table frame='all'><title></title> + <tgroup cols='3' align='left' colsep='1' rowsep='1'> + <colspec colname='c1'/> + <colspec colname='c2'/> + <colspec colname='c3'/> + <thead> + <row> + <entry role="class-title" >Actor</entry> + <entry role="class-name" namest="c2" nameend="c3" ><xsl:value-of select="$element_name"/></entry> + </row> + </thead> + <tbody> + <xsl:if test="count($comment) > 0"> + <row> + <entry role="comment" namest="c1" nameend="c3" ><para><xsl:value-of select="$comment"/></para></entry> + </row> + </xsl:if> + + <xsl:call-template name="specifications"/> + + <xsl:call-template name="realizations"/> + + <xsl:call-template name="supertypes"/> + + <xsl:call-template name="subtypes"/> + + <xsl:call-template name="associations"> + <xsl:with-param name="source" select="$xmi_id"/> + </xsl:call-template> + + </tbody> + </tgroup> + </table> + + </section> +</xsl:template> + +<!-- Use Case --> +<xsl:template match="UML:UseCase"> + <xsl:variable name="element_name" select="@name"/> + <xsl:variable name="xmi_id" select="@xmi.id" /> + <xsl:variable name="comment" select="@comment" /> + + <section> + <title><xsl:value-of select="$element_name"/></title> + + <table frame='all'><title></title> + <tgroup cols='3' align='left' colsep='1' rowsep='1'> + <colspec colname='c1'/> + <colspec colname='c2'/> + <colspec colname='c3'/> + <thead> + <row> + <entry role="class-title" >Use Case</entry> + <entry role="class-name" namest="c2" nameend="c3" ><xsl:value-of select="$element_name"/></entry> + </row> + </thead> + <tbody> + <xsl:if test="count($comment) > 0"> + <row> + <entry role="comment" namest="c1" nameend="c3" ><para><xsl:value-of select="$comment"/></para></entry> + </row> + </xsl:if> + + <xsl:call-template name="specifications"/> + + <xsl:call-template name="realizations"/> + + <xsl:call-template name="supertypes"/> + + <xsl:call-template name="subtypes"/> + + <xsl:call-template name="associations"> + <xsl:with-param name="source" select="$xmi_id"/> + </xsl:call-template> + + </tbody> + </tgroup> + </table> + + </section> +</xsl:template> + + +<!-- Interface --> +<xsl:template match="UML:Interface"> + <xsl:variable name="element_name" select="@name"/> + <xsl:variable name="comment" select="@comment" /> + <xsl:variable name="realizations" + select="Foundation.Core.ModelElement.supplierDependency/ + Foundation.Core.Abstraction"/> + <xsl:variable name="generalizations" + select="UML:Generalization"/> + <xsl:variable name="specializations" + select="Foundation.Core.GeneralizableElement.specialization/ + Foundation.Core.Generalization"/> + <xsl:variable name="class_operations" + select="UML:Classifier.feature/UML:Operation" /> + <section> + <title><xsl:value-of select="$element_name"/></title> + <table frame='all'><title></title> + <tgroup cols='3' align='left' colsep='1' rowsep='1'> + <colspec colname='c1'/> + <colspec colname='c2'/> + <colspec colname='c3'/> + <thead> + <row> + <entry role="class-title" >Interface</entry> + <entry role="class-name" namest="c2" nameend="c3" ><xsl:value-of select="$element_name"/></entry> + </row> + </thead> + <tbody> + <xsl:if test="count($comment) > 0"> + <row> + <entry role="comment" namest="c1" nameend="c3" ><para><xsl:value-of select="$comment"/></para></entry> + </row> + </xsl:if> + <xsl:if test="count($class_operations) = 0"> + <row> + <entry namest="c1" nameend="c3" ><para/></entry> + </row> + </xsl:if> + + <xsl:if test="count($realizations) = 0 + and count($generalizations) = 0 + and count($specializations) = 0 + and count($class_operations) = 0"> + </xsl:if> + <xsl:call-template name="realizations"/> + <xsl:call-template name="supertypes"/> + <xsl:call-template name="subtypes"/> + <xsl:call-template name="operations"/> + </tbody> + </tgroup> + </table> + + </section> +</xsl:template> + + +<!-- Class --> +<xsl:template match="UML:Class"> + <xsl:variable name="element_name" select="@name"/> + <xsl:variable name="xmi_id" select="@xmi.id" /> + <xsl:variable name="comment" select="@comment" /> + <xsl:variable name="class_attributes" + select="UML:Classifier.feature/UML:Attribute" /> + <xsl:variable name="class_operations" + select="UML:Classifier.feature/UML:Operation" /> + + <section> + <title><xsl:value-of select="$element_name"/></title> + + <table frame='all'><title></title> + <tgroup cols='3' align='left' colsep='1' rowsep='1'> + <colspec colname='c1'/> + <colspec colname='c2'/> + <colspec colname='c3'/> + <thead> + <row> + <entry role="class-title" >Class</entry> + <entry role="class-name" namest="c2" nameend="c3" ><xsl:value-of select="$element_name"/></entry> + </row> + </thead> + <tbody> + <xsl:if test="count($comment) > 0"> + <row> + <entry role="comment" namest="c1" nameend="c3" ><para><xsl:value-of select="$comment"/></para></entry> + </row> + </xsl:if> + <xsl:if test="count($class_attributes) = 0 + and count($class_operations) = 0"> + <row> + <entry namest="c1" nameend="c3" ><para/></entry> + </row> + </xsl:if> + + <xsl:call-template name="specifications"/> + + <xsl:call-template name="realizations"/> + + <xsl:call-template name="supertypes"/> + + <xsl:call-template name="subtypes"/> + + <xsl:call-template name="associations"> + <xsl:with-param name="source" select="$xmi_id"/> + </xsl:call-template> + + <xsl:call-template name="attributes"/> + + <xsl:call-template name="operations"/> + </tbody> + </tgroup> + </table> + + </section> +</xsl:template> + + +<xsl:template match="diagrams/diagram"> + <xsl:variable name="xmi_id" select="@xmi.id" /> + <xsl:comment >diagrambegin<xsl:value-of select="position()"/>namebegin<xsl:value-of select="@name"/>nameend</xsl:comment> + <xsl:comment >diagram<xsl:value-of select="position()"/>documentationbegin<xsl:value-of select="@documentation"/>documentationend</xsl:comment> + + <section> + <title><xsl:value-of select="@name"/></title> + <para> + <xsl:value-of select="@documentation"/> + </para> + <mediaobject> + <imageobject> + <imagedata format="PNG"> + <xsl:attribute name="fileref"><xsl:value-of select="@name"/> + <xsl:text>.png</xsl:text> + </xsl:attribute> + </imagedata> + </imageobject> + </mediaobject> + </section> + <xsl:if test="widgets/actorwidget"> + <section> + <title>&actor;</title> + <xsl:for-each select="widgets/actorwidget"> + <xsl:call-template name="actor"/> + </xsl:for-each> + </section> + </xsl:if> + + <xsl:if test="widgets/usecasewidget"> + <section> + <title>&usecase;</title> + <xsl:for-each select="widgets/usecasewidget"> + <xsl:call-template name="usecase"/> + </xsl:for-each> + </section> + </xsl:if> + + <xsl:if test="widgets/classwidget"> + <section> + <title>&classes;</title> + <para/> + <!--xsl:for-each select="widgets/classwidget"> + <xsl:call-template name="class"/> + </xsl:for-each--> + </section> + </xsl:if> + + <xsl:comment >diagramend<xsl:value-of select="position()"/></xsl:comment> +</xsl:template> + + +<!-- The following template is designed to be called for Abstractions with the "realize" + stereotype, i.e. Realization relationships. It formats the name of the supplier of the + Abstraction dependency, i.e. the class or interface specifying the behaviour of the + client in the dependency. +--> +<!-- Specifications (interface or class) --> +<xsl:template name="specifications"> + + <!-- Abstractions identify specifications --> + <xsl:variable name="specifications" + select="Foundation.Core.ModelElement.clientDependency/ + Foundation.Core.Abstraction"/> + + <xsl:if test="count($specifications) > 0"> + <section> + <title>Specifications:</title> + <xsl:for-each select="$specifications"> + <!-- get the supplier in the abstraction --> + <xsl:variable name="abstraction" + select="key('abstraction', ./@xmi.idref)" /> + <xsl:variable name="target" + select="$abstraction/ + Foundation.Core.Dependency.supplier/ + */@xmi.idref" /> + <xsl:call-template name="classify"> + <xsl:with-param name="target" select="$target"/> + </xsl:call-template> + + <xsl:if test="position() != last()"> + <xsl:text>, </xsl:text> + </xsl:if> + </xsl:for-each> + </section> + </xsl:if> + +</xsl:template> + + +<!-- The following template is designed to be called for Abstractions with the "realize" + stereotype, i.e. Realization relationships. It formats the name of the client of the + Abstraction dependency, i.e. the class realizing the specification defined by the + supplier in the dependency. +--> +<!-- Realizations (of interface) --> +<xsl:template name="realizations"> + + <!-- Abstractions identify realizations --> + <xsl:variable name="realizations" + select="Foundation.Core.ModelElement.supplierDependency/ + Foundation.Core.Abstraction"/> + + <xsl:if test="count($realizations) > 0"> + <section> + <title>Realizations:</title> + <xsl:for-each select="$realizations"> + + <!-- get the client in the abstraction --> + <xsl:variable name="abstraction" + select="key('abstraction', ./@xmi.idref)" /> + <xsl:variable name="target" + select="$abstraction/ + Foundation.Core.Dependency.client/ + */@xmi.idref" /> + <xsl:call-template name="classify"> + <xsl:with-param name="target" select="$target"/> + </xsl:call-template> + + <xsl:if test="position() != last()"> + <xsl:text>, </xsl:text> + </xsl:if> + </xsl:for-each> + </section> + </xsl:if> + +</xsl:template> + + + +<!-- Supertypes (inheritance) --> +<xsl:template name="supertypes"> + + <!-- Generalizations identify supertypes --> + <xsl:variable name="generalizations" + select="UML:Generalization"/> + + <xsl:if test="count($generalizations) > 0"> + <section> + <title>Supertypes:</title> + <xsl:for-each select="$generalizations"> + + <!-- get the parent in the generalization --> + <xsl:variable name="generalization" + select="key('generalization', ./@xmi.idref)" /> + <xsl:variable name="target" + select="$generalization/ + Foundation.Core.Generalization.parent/ + */@xmi.idref" /> + <xsl:call-template name="classify"> + <xsl:with-param name="target" select="$target"/> + </xsl:call-template> + + <xsl:if test="position() != last()"> + <xsl:text>, </xsl:text> + </xsl:if> + </xsl:for-each> + </section> + </xsl:if> +</xsl:template> + + +<!-- Subtypes (inheritance) --> +<xsl:template name="subtypes"> + + <!-- Specializations identify subtypes --> + <xsl:variable name="specializations" + select="Foundation.Core.GeneralizableElement.specialization/ + Foundation.Core.Generalization"/> + + <xsl:if test="count($specializations) > 0"> + <section> + <title>Subtypes:</title> + <xsl:for-each select="$specializations"> + + <!-- get the child in the generalization --> + <xsl:variable name="generalization" + select="key('generalization', ./@xmi.idref)" /> + <xsl:variable name="target" + select="$generalization/ + Foundation.Core.Generalization.child/ + */@xmi.idref" /> + <xsl:call-template name="classify"> + <xsl:with-param name="target" select="$target"/> + </xsl:call-template> + + <xsl:if test="position() != last()"> + <xsl:text>, </xsl:text> + </xsl:if> + </xsl:for-each> + </section> + </xsl:if> +</xsl:template> + + +<!-- Associations --> +<xsl:template name="associations"> + <xsl:param name="source"/> + + <xsl:variable name="association_ends" + select="//UML:AssociationEnd[@type=$source]" /> + + <xsl:if test="count($association_ends) > 0"> + <section> + <title>Associations</title> + <para>visibility, type, properties.</para> + + <xsl:for-each select="$association_ends"> + <xsl:for-each select="preceding-sibling::UML:AssociationEnd | + following-sibling::UML:AssociationEnd"> + + <xsl:call-template name="association_end" /> + + </xsl:for-each> + </xsl:for-each> + </section> + </xsl:if> +</xsl:template> + + +<!-- Association End --> +<xsl:template name="association_end"> + <!-- Visibility --> + <para> + <!--role="feature-detail"--> + <xsl:variable name="visibility" + select="@visibility" /> + <xsl:choose> + <xsl:when test="string-length($visibility) > 0"> + <xsl:value-of select="$visibility"/> + </xsl:when> + <xsl:otherwise> + <xsl:text disable-output-escaping="yes">&nbsp;</xsl:text> + </xsl:otherwise> + </xsl:choose> + </para> + + <!-- Type --> + <para> + <!--role="feature-detail"--> + <xsl:variable name="target" + select="Foundation.Core.AssociationEnd.type/*/@xmi.idref" /> + + <xsl:call-template name="classify"> + <xsl:with-param name="target" select="$target"/> + </xsl:call-template> + </para> + + <!-- Properties --> + <para> + <!--role="feature-detail"--> + <!-- Rolename --> + <xsl:variable name="rolename" select="@name"/> + + <!--role="property-name"--> + Rolename: + <xsl:choose> + <xsl:when test="string-length($rolename) > 0"> + <xsl:value-of select="$rolename"/> + </xsl:when> + <xsl:otherwise>(none)</xsl:otherwise> + </xsl:choose> + </para> + + <!-- Multiplicity --> + <xsl:apply-templates select=".//Foundation.Data_Types.Multiplicity" /> + + <!-- Navigable --> + <xsl:variable name="navigable" + select="Foundation.Core.AssociationEnd.isNavigable/@xmi.value"/> + <xsl:if test="string-length($navigable) > 0"> + + <para> + <!--role="property-name"--> + Navigable: <xsl:value-of select="$navigable"/> + </para> + </xsl:if> + + <!-- Ordering --> + <xsl:variable name="ordering" + select="Foundation.Core.AssociationEnd.ordering/@xmi.value"/> + <xsl:if test="string-length($ordering) > 0"> + <para> + <!--role="property-name"--> + Ordering: <xsl:value-of select="$ordering"/> + </para> + </xsl:if> +</xsl:template> + + +<!-- Multiplicity (definition) --> +<xsl:template match="Foundation.Data_Types.Multiplicity[@xmi.id]"> + + <para> + <!--role="property-name"--> + Multiplicity: + + <xsl:variable name="lower" + select=".//Foundation.Data_Types.MultiplicityRange.lower"/> + + <xsl:variable name="upper" + select=".//Foundation.Data_Types.MultiplicityRange.upper"/> + + <xsl:value-of select="$lower" /> + <xsl:if test="$upper != $lower"> + <xsl:text>..</xsl:text> + <xsl:value-of select="$upper" /> + </xsl:if> + </para> + +</xsl:template> + +<!-- Multiplicity (reference) --> +<xsl:template match="Foundation.Data_Types.Multiplicity[@xmi.idref]"> + <xsl:apply-templates select="key('multiplicity', @xmi.idref)" /> +</xsl:template> + + + +<!-- Attributes --> +<xsl:template name="attributes"> + <xsl:variable name="class_attributes" + select="UML:Classifier.feature/UML:Attribute" /> + <xsl:if test="count($class_attributes) > 0"> + <row> + <entry role="info-title" namest="c1" nameend="c3" >Attributes:</entry> + </row> + <row> + <entry role="feature-heading">visibility</entry> + <entry role="feature-heading">type</entry> + <entry role="feature-heading">name</entry> + </row> + <xsl:apply-templates select="UML:Classifier.feature/ + UML:Attribute" /> + </xsl:if> +</xsl:template> + + +<xsl:template match="UML:Attribute"> + <xsl:variable name="target" + select='@type'/> + + + <row> + <entry role="feature-detail"> + <xsl:value-of select="@visibility"/> + </entry> + + <entry role="feature-detail"> + <xsl:call-template name="classify"> + <xsl:with-param name="target" select="$target" /> + </xsl:call-template> + </entry> + + <entry role="feature-detail"> + <xsl:value-of select="@name"/> + </entry> + </row> + + <row> + <entry role="comment"/> + <entry namest="c2" nameend="c3" role="comment"><xsl:value-of select="@comment"/></entry> + </row> + +</xsl:template> + + + +<!-- Operations --> +<xsl:template name="operations"> + <xsl:variable name="class_operations" + select="UML:Classifier.feature/UML:Operation" /> + <xsl:if test="count($class_operations) > 0"> + <row> + <entry role="info-title" namest="c1" nameend="c3" ><para>Operations:</para></entry> + </row> + <row> + <entry role="feature-heading" ><para>visibility</para></entry> + <entry role="feature-heading" ><para>return</para></entry> + <entry role="feature-heading" ><para>name</para></entry> + </row> + + <xsl:apply-templates select="UML:Classifier.feature/ + UML:Operation" /> + </xsl:if> +</xsl:template> + + +<xsl:template match="UML:Operation"> + + <xsl:variable name="parameters" + select="UML:BehavioralFeature.parameter/ + UML:Parameter[@kind!='return']" /> + + <xsl:variable name="return" + select="UML:BehavioralFeature.parameter/ + UML:Parameter[@kind='return']" /> + + <xsl:variable name="target" + select="$return/@type" /> + + <row> + <entry role="feature-detail"> + <xsl:value-of select="@visibility" /> + </entry> + + <entry role="feature-detail"> + + <xsl:choose> + <xsl:when test="string-length($target) = 0"> + <para role="datatype"><xsl:text>void</xsl:text></para> + </xsl:when> + + <xsl:otherwise> + <xsl:call-template name="classify"> + <xsl:with-param name="target" select="$target" /> + </xsl:call-template> + </xsl:otherwise> + </xsl:choose> + + </entry> + + <entry role="feature-detail"> + <xsl:value-of select="@name"/> + </entry> + + + </row> + + <row> + <entry role="comment"/> + <entry namest="c2" nameend="c3" role="comment"><xsl:value-of select="@comment"/></entry> + </row> + + <xsl:variable name="parameter-count" select="count($parameters)" /> + + <xsl:if test="not(normalize-space($parameter-count)='0')"> + + <row> + <entry role="feature-detail" > + <xsl:text disable-output-escaping="yes">&nbsp;</xsl:text> + </entry> + + <entry role="parameter-heading" valign="top">parameters:</entry> + <entry bgcolor="#ffffff" align="right"> + <!--table width="85%" align="right" cellpadding="0" cellspacing="0" border="0"> + <xsl:apply-templates select="$parameters" /> + </table--> + </entry> + </row> + + </xsl:if > + +</xsl:template> + + + +<!-- Parameter --> +<xsl:template match="UML:Parameter"> + <xsl:variable name="target" + select="@type" /> + + <row> + <entry role="feature-detail" width="45%"> + <xsl:call-template name="classify"> + <xsl:with-param name="target" select="$target" /> + </xsl:call-template> + </entry> + + <entry role="feature-detail" width="55%"> + <xsl:value-of select="@name"/> + </entry> + </row> +</xsl:template> + + +<!-- Classification --> +<xsl:template name="classify"> + <xsl:param name="target"/> + + <xsl:variable name="classifier" + select="key('classifier', $target)" /> + + <xsl:variable name="classifier_name" + select="$classifier/@name" /> + + <xsl:variable name="type" select="name($classifier)" /> + + <!-- Get the type of the classifier (class, interface, datatype) --> + <xsl:variable name="classifier_type"> + <xsl:choose> + <xsl:when test="$type='UML:Class'">classifier</xsl:when> + <xsl:when test="$type='UML:Interface'">interface</xsl:when> + <xsl:when test="$type='UML:DataType'">datatype</xsl:when> + <xsl:otherwise>classifier</xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:choose> + <!-- Datatypes don't have hyperlinks --> + <xsl:when test="$type='UML:DataType'"> + <span role="datatype"> + <xsl:value-of select="$classifier_name"/> + </span> + </xsl:when> + + <!-- Classes and Interfaces have hyperlinks --> + <!-- The classifier type is used to style appropriately --> + <xsl:otherwise> + <xsl:if test="string-length($classifier) > 0"> + <!--a role={$classifier_type}" href="#{$classifier_name}"--> + <xsl:value-of select="$classifier_name"/> + <!--/a--> + </xsl:if> + </xsl:otherwise> + </xsl:choose> + +</xsl:template> + +<!--xsl:template match="XMI.content"> + + <xsl:comment >maintitlebegin1&title1;maintitleend1</xsl:comment> + <xsl:comment >maintitlebegin2&title2;maintitleend2</xsl:comment> + <xsl:apply-templates select="diagrams/diagram"/> +</xsl:template--> + + + <xsl:template name="actor"> + <xsl:param name = "idvalue"><xsl:value-of select="@xmi.id"/></xsl:param> + <!--td valign="top"--> + <para> + <!--role="push"--> + <xsl:for-each select="//XMI.content/umlobjects/UML:Actor"> + <xsl:if test="@xmi.id = $idvalue"> + <emphasis><xsl:value-of select="@name"/>:</emphasis> + <xsl:value-of select="@documentation"/> + </xsl:if> + </xsl:for-each > + </para> + <!--/td--> + </xsl:template> + + <xsl:template name="usecase"> + <xsl:param name = "idvalue"><xsl:value-of select="@xmi.id"/></xsl:param> + <!--td valign="top"--> + <para> + <!--role="push"--> + <xsl:for-each select="//XMI.content/umlobjects/UML:UseCase"> + <xsl:if test="@xmi.id = $idvalue"> + <emphasis><xsl:value-of select="@name"/>:</emphasis> + <xsl:value-of select="@documentation"/> + + </xsl:if> + </xsl:for-each > + </para> + <!--/td--> + </xsl:template> + + <xsl:template name="class"> + <xsl:param name = "idvalue"><xsl:value-of select="@xmi.id"/></xsl:param> + <!--td valign="top"--> + <div role="push"> + <xsl:for-each select="//XMI.content/umlobjects/UML:Class"> + <xsl:if test="@xmi.id = $idvalue"> + <div role="boldtext">&packagename;<xsl:value-of select="@package"/></div> + <div role="boldtext">&classname;<xsl:value-of select="@name"/></div> + <xsl:value-of select="@documentation"/> + <div role="push"> + + Stereotype: <xsl:value-of select="@stereotype"/> + + Abstarct: + <xsl:if test="@abstract='1'"> + <xsl:text>&yes;</xsl:text> + </xsl:if> + <xsl:if test="@abstract='0'"> + <xsl:text>&no;</xsl:text> + </xsl:if> + + Visibility: + <xsl:if test="@scope='200'"> + <xsl:text>public</xsl:text> + </xsl:if> + <xsl:if test="@scope='201'"> + <xsl:text>private</xsl:text> + </xsl:if> + <xsl:if test="@scope='202'"> + <xsl:text>protected</xsl:text> + </xsl:if> + + <xsl:call-template name="attribute"/> + <xsl:call-template name="operation"/> + </div> + </xsl:if> + </xsl:for-each > + </div> + <!--/td--> + </xsl:template> + + + <xsl:template name="attribute"> + <!--td valign="top"--> + <div role="boldtext">&attributes;</div> + + <xsl:for-each select="UML:Attribute"> + <xsl:value-of select="@name"/><xsl:text> - </xsl:text><xsl:value-of select="@type"/> + Static: + <xsl:if test="@static='1'"> + <xsl:text>&yes;</xsl:text> + </xsl:if> + <xsl:if test="@static='0'"> + <xsl:text>&no;</xsl:text> + </xsl:if> + + Visibility: + <xsl:if test="@scope='200'"> + <xsl:text>public</xsl:text> + </xsl:if> + <xsl:if test="@scope='201'"> + <xsl:text>private</xsl:text> + </xsl:if> + <xsl:if test="@scope='202'"> + <xsl:text>protected</xsl:text> + </xsl:if> + + Default �t�: <xsl:value-of select="@value"/> + + <xsl:value-of select="@documentation"/> + + </xsl:for-each > + <!--/td--> + </xsl:template> + + <xsl:template name="operation"> + <entry valign="top"> + <div role="boldtext">&metodes;</div> + + <xsl:for-each select="UML:Operation"> + <i> + <xsl:if test="@abstract='1'"> + <xsl:text>abstract </xsl:text> + </xsl:if> + <xsl:if test="@scope='200'"> + <xsl:text>public </xsl:text> + </xsl:if> + <xsl:if test="@scope='201'"> + <xsl:text>private </xsl:text> + </xsl:if> + <xsl:if test="@scope='202'"> + <xsl:text>protected </xsl:text> + </xsl:if> + + <xsl:value-of select="@type"/><xsl:text> </xsl:text> + + <xsl:value-of select="@name"/><xsl:text>(</xsl:text> + + <xsl:apply-templates select="UML:Parameter" mode="diagram"/> + <xsl:text>)</xsl:text> + + </i> + <xsl:value-of select="@documentation"/> + ¶meters; + <xsl:for-each select="UML:Parameter"> + <div role="push"> + <xsl:value-of select="@type"/> + <xsl:text> </xsl:text> + <xsl:value-of select="@name"/> + + <xsl:value-of select="@documentation"/> + + </div> + </xsl:for-each> + + </xsl:for-each > + </entry> + </xsl:template> + + <xsl:template match="UML:Parameter" mode="diagram"> + + <xsl:value-of select="@type"/> + <xsl:text> </xsl:text> + <xsl:value-of select="@name"/> + <xsl:if test="position()!=last()"> + <xsl:text>, </xsl:text> + </xsl:if> + + </xsl:template> +</xsl:stylesheet> |