Current Workflow Rules T1 Rules Extensions XMLfile DOM processing with Meta API-calls Model 1 T2 Model 2 Code Generation (Smarty) Source code PP formatted sourcecode DTD V1 Rules XMI 1/21
Anbindung eines graphischen Frontends Optionen: Entwicklung eines graphischen Editors (z.b. mit Hilfe des Eclipse Graphical editing framework - GEF) Einsatz eines handelsüblichen UML-Modellierungstools (Magic Draw, Poseidon,...) mit XMI-Export XMI ist das Standardaustauschformat für UML Modelle (OMG) Hauptbestandteile von XMI: XMI model (semantische Information des UML-Modells) XMI diagram (Darstellungsinformationen) Aktuelle Version: 2.1 Ein sehr gesprächiges Format XMI 2/21
Werkzeuge UML - Editor Magic Draw UML 17.04 Unterstützt XMI 2.1 Trialversion verfügbar Homepage: http://www.magicdraw.com/ XSLT-Prozessor (Kommandozeile) XML Editor Oxygen Version 9.3 Im Poolraum installiert Trialversion verfügbar Xalan-C++ (Apache 2 License) Download von http://xml.apache.org/xalan-c/ (benötigt zusätzlich Xerces-C++) XQuery-Prozessor (Kommandozeile) Zorba (Apache 2 License) Download von http://www.zorba-xquery.com/html/download XMI 3/21
UML Klassenmodell XMI 4/21
Struktur XMI (1) XMI 5/21
Struktur XMI (2) XMI 6/21
Struktur XMI (3) XMI 7/21
Struktur XMI (4) XMI 8/21
XML-Element f. Klasse <packagedelement xmi:type="uml:class" xmi:id="_485" name="film" visibility="public" isleaf="false" isabstract="false" isactive="false"> <ownedattribute xmi:type="uml:property" xmi:id="..._503" name="titel" visibility="private" isordered="false" isunique="true" isleaf="false"...> <type xmi:type="uml:primitivetype" href="...uml.xml#string"> <xmi:extension extender="magicdraw UML 16.5"> <referenceextension referentpath="...s::primitivetypes::string" referenttype="primitivetype"/> </xmi:extension> </type> </ownedattribute> <ownedattribute xmi:type="uml:property" xmi:id="_505" name="erscheinungsjahr" visibility="private"... > <type xmi:type="uml:datatype" href="uml_standard_pr...3305590699_364818_1"> <xmi:extension extender="magicdraw UML 16.5"> <referenceextension referentpath="...::datatypes::date" referenttype="datatype"/> </xmi:extension> </type> </ownedattribute> XMI 9/21
<ownedattribute xmi:type="uml:property" xmi:id="..._541" name="schauspieler" visibility="public"... type="..._509"> <uppervalue xmi:type="uml:literalunlimitednatural" xmi:id="..._560" name="" visibility="public" value="*"/> <lowervalue xmi:type="uml:literalinteger" xmi:id="..._559" name="" visibility="public" value="0"/> </ownedattribute> <ownedattribute xmi:type="uml:property" xmi:id="..._568" name="regisseur" visibility="public"... type="..._509" association="..._567"> <xmi:extension extender="magicdraw UML 16.5"> <modelextension> <uppervalue xmi:id="..._592" name=""visibility="public" value="1"/> </modelextension> </xmi:extension> <lowervalue xmi:type="uml:literalinteger" xmi:id="..._591" name="" visibility="public" value="0"/> </ownedattribute> </packagedelement> XMI 10/21
XML-Element f. Assoziation <packagedelement xmi:type="uml:association" xmi:id="..._539" name="spielt_mit" visibility="public" > <memberend xmi:idref="..._540"/> <memberend xmi:idref="..._541"/> </packagedelement> <packagedelement xmi:type="uml:association" xmi:id="..._567" name="fuehrt_regie" visibility="public" > <memberend xmi:idref="..._568"/> <memberend xmi:idref="..._569"/> </packagedelement> XMI 11/21
Oxygen - XPath Builder XMI 12/21
XPath zur Extraktion relevanter Teile Klassen des Modells /xmi:xmi/uml:model/packagedelement[@xmi:type='uml:class'] Attribute einer Klasse /xmi:xmi/uml:model/packagedelement[@xmi:type='uml:class' and @name='film'] /ownedattribute[type]/@name Assoziationsenden einer Klasse /xmi:xmi/uml:model/packagedelement[@xmi:type='uml:class' and @name='film'] /ownedattribute[@association]/@name Assoziationen des Modells /xmi:xmi/uml:model/packagedelement[@xmi:type='uml:association'] ID s der Assoziationsenden einer Assoziation /xmi:xmi/uml:model/packagedelement[@xmi:id='_16_5_ca5026a_1241545088561_668956_605'] /memberend/@xmi:idref XMI 13/21
... puh, und jetzt? Möglichkeiten: Anpassen des Importfilters auf XMI Transformation von XMI in unser Format XQuery (z.b. mittels Zorba) XSLT (z.b. mittels Xalan) XMI 14/21
XQuery Transformation (1) declare namespace xmi = "http://www.omg.org/spec/xmi/20110701"; declare namespace uml="http://www.omg.org/spec/uml/20110701"; for $class in /xmi:xmi/uml:model/packagedelement[@xmi:type='uml:class'] return <class name="{$class/@name}"/> <?xml version="1.0" encoding="utf-8"?> <class name="film"/> <class name="person"/> XMI 15/21
XQuery Transformation (2) declare namespace xmi = "http://schema.omg.org/spec/xmi/2.1"; declare namespace uml="http://schema.omg.org/spec/uml/2.2"; for $class in /xmi:xmi/uml:model/packagedelement[@xmi:type='uml:class'] return <class name="{$class/@name}"> {for $attribute in $class/ownedattribute[type] return <attribute name="{$attribute/@name}"/>} </class> <?xml version="1.0" encoding="utf-8"?> <class name="film"> <attribute name="titel"/> <attribute name="erscheinungsjahr"/> </class> <class name="person"> <attribute name="nachname"/> <attribute name="vorname"/> </class> XMI 16/21
attribute/@type: analog Attribut name + fn:substring-after($string, $delim) Element relation: analog Element attribute mit xml-attributen: @min @max @role @relation_name Hinweis: z.t. sind die Hierarchien bei den Kardinalitäten und Datentypen leicht unterschiedlich (--> // statt / benutzen) XMI 17/21
Weitere Modelltransformation Unsere XMI Datei ist plattformunabhängig und kennt deshalb nicht das Konzept des Primärschlüssels Wie kann diese Information hinzugefügt werden? Modell Transformation mithilfe der Metamodell API XSLT Transformation Eingabaut in Transformation von XMI -> unserem XML Separate Transformation unseres XML Modells (Stylesheet siehe nächste Seite) XMI 18/21
XSLT-Transformation <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform"> <xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes" doctype-system="my-meta.dtd"/> handle all existing attributes <xsl:template match="class"> <class> add id attribute <xsl:apply-templates select="@*"/> <attribute name="id" type="integer" primary-key="true"/> <xsl:apply-templates select="node()"/> </class> handle all subelements </xsl:template> <xsl:template match="@* node()"> <xsl:copy> <xsl:apply-templates select="@* node()"/> </xsl:copy> </xsl:template> identity stylesheet </xsl:stylesheet> XMI 19/21
Current Workflow new features in blue UML modeling tool Stylesheet XSLT Rules T1 Rules Rules T3 Extensions XMI XQuery Engine XML- File DOM processing with Meta API-calls Model 1 T2 Model 2 Code Generation (Smarty) Source Code PP Formatted Source Code XQuery - DTD V1 Rules XMI 20/21
Übung 5 Erweiterung des Generators um eine Komponente die XMI (Version 2.1) in unser XML-Format übersetzt. XSLT, bzw. XQueryTransformationen durch Kommandotool (z.b. Xalan, Zorba) Entwicklung eines eigenen, durchgängigen Szenarios, das alle Schritte der Codegenerierung umfasst Steuerung durch makefile XMI 21/21