XMI is a standard interchange format for meta data information which can be used to exchange models between different modelling tools. This article provides an example of how to generate an XMI in SystemWeaver targeted for Enterprise Architect containing:
- XMI model
- Enterprise Architect extensions
- Enterprise Architect custom profiles
SystemWeaver builds on a configurable meta model where the information can be tailored to fit the process and methods that a company uses. With regards to XMI, this means that every customer configures their own exports based on the data that they have. This article describes how you can export to XMI files using the built-in XML generator in SystemWeaver. The example provided below uses a test server and the Demo sqlite training database.
Prerequisites
- Familiarity with SystemWeaver concepts such as Items, Parts and Attributes, and also with the GUI and common operations of the swExplorer.
- Knowledge of XML.
- An installation of the SystemWeaver client (swExplorer).
- A server (you can set up your own server by following the instructions in Setting up a Test Server).
- A database (you can use the Database for SystemWeaver Demo).
Configuring the XML
We generate XMI files using the configurable XML language in SystemWeaver.
- Open the Design function (Adaptive cruise, ID: x04000000000007B1) in the Demo database. The design function contains a number of components with interface and requirements in a layered structure.
- In the View drop-down menu, select XMLs > Sandbox to create a new configurable XMI.
An XMI example is provided at the bottom of this article and demonstrates how we traverse the data to create the XMI file.
Context
In the top part of the file, create a context for the components, interface and the contained sections and requirements using <Context>.
Model
Next, create the model part using five templates. We recommend that you copy and paste these templates as they are used in any database.
Extensions
The extensions are created using five other templates where each element created references the elements created in the model.
Custom Profile Information
The last part of the script adds custom profile information to some of the elements created.
Viewing and Exporting
You can view the XMI that you have created by switching to the View tab and can save the file by using the Save as… button.
Then, you can import the XMI file in to Enterprise Architect. For our example, the imported data would look as shown below:
Example XMI
<XDocument name="xmi:XMI"> <Options> <Suffix>xmi</Suffix> </Options> <XAttribute name="xmlns:uml" value="http://www.omg.org/spec/UML/20131001"/> <XAttribute name="xmlns:xmi" value="http://www.omg.org/spec/XMI/20131001"/> <XAttribute name="xmlns:umldi" value="http://www.omg.org/spec/UML/20131001/UMLDI"/> <XAttribute name="xmlns:dc" value="http://www.omg.org/spec/UML/20131001/UMLDC"/> <XAttribute name="xmlns:thecustomprofile" value="http://www.sparxsystems.com/profiles/thecustomprofile/1.0"/> <XAttribute name="xmlns:sysml" value="http://www.omg.org/spec/SysML/20080501/SysML-profile"/> <Context name="x"> <AddParts owner="main" sid="ITFC" part="Comps" defobj="Comp"/> <AddParts owner="Comp" sid="ARPP" part="SendSigs" defobj="Sig"/> <AddParts owner="Comp" sid="ARRP" part="RecSigs" defobj="Sig"/> <AddParts owner="Comp" sid="5IRR" part="Secs" defobj="Sec"/> <AddParts owner="Sec" sid="5IDS" part="SubSecs" defobj="+Sec"/> <AddParts owner="Sec" sid="IDRE" part="Reqs" defobj="Req"/> </Context> <Template name="FunctionClass"> <ForEachInContext name="x" group="Comp"> <XElement name="packagedElement"> <XAttribute name="xmi:type" value="uml:Class"/> <XAttribute name="xmi:id" value="EAID_#{AncestorHandle}"/> <XAttribute name="name" value="#{Name}"/> <ContextGoForwardToPart part="RecSigs"> <XElement name="ownedAttribute"> <XAttribute name="xmi:type" value="uml:Property"/> <XAttribute name="xmi:id" value="EAID_#{AncestorHandle}"/> <XAttribute name="association" value="EAID_ASS#{AncestorHandle}"/> <XElement name="type"> <ContextGoForward> <XAttribute name="xmi:idref" value="EAID_#{AncestorHandle}"/> </ContextGoForward> </XElement> </XElement> </ContextGoForwardToPart> <ContextGoForwardToPart part="SendSigs"> <XElement name="ownedAttribute"> <XAttribute name="xmi:type" value="uml:Property"/> <XAttribute name="xmi:id" value="EAID_#{AncestorHandle}"/> <XAttribute name="association" value="EAID_ASS#{AncestorHandle}"/> <XElement name="type"> <ContextGoForward> <XAttribute name="xmi:idref" value="EAID_#{AncestorHandle}"/> </ContextGoForward> </XElement> </XElement> </ContextGoForwardToPart> </XElement> </ForEachInContext> </Template> <Template name="SignalClass"> <ForEachInContext name="x" group="Sig"> <XElement name="packagedElement"> <!-- XAttribute name="xmi:type" value="uml:Class"/ --> <XAttribute name="xmi:type" value="uml:Signal"/> <XAttribute name="xmi:id" value="EAID_#{AncestorHandle}"/> <XAttribute name="name" value="#{Name}"/> </XElement> </ForEachInContext> </Template> <Template name="CompSignalDetails"> <Parameter name="Dir" as="String"/> <XElement name="packagedElement"> <XAttribute name="xmi:type" value="uml:Association"/> <XAttribute name="xmi:id" value="EAID_ASS#{AncestorHandle}"/> <XElement name="memberEnd"> <XAttribute name="xmi:idref" value="EAID_#{AncestorHandle}"/> </XElement> <XElement name="memberEnd"> <XAttribute name="xmi:idref" value="EAID_src#{AncestorHandle}"/> </XElement> <XElement name="ownedEnd"> <XAttribute name="xmi:type" value="uml:Property"/> <XAttribute name="name" value="#{?$Dir}"/> <XAttribute name="xmi:id" value="EAID_src#{AncestorHandle}"/> <XAttribute name="association" value="EAID_ASS#{AncestorHandle}"/> <XAttribute name="aggregation" value="shared"/> <XElement name="type"> <ContextGoBack> <XAttribute name="xmi:idref" value="EAID_#{AncestorHandle}"/> </ContextGoBack> </XElement> </XElement> </XElement> </Template> <Template name="CompSignalAssociation"> <ForEachInContext name="x" group="Sig"> <ContextGoBackToPart part="RecSigs"> <ApplyTemplate name="CompSignalDetails"> <WithParam name="Dir" select="'Rx'"/> </ApplyTemplate> </ContextGoBackToPart> <ContextGoBackToPart part="SendSigs"> <ApplyTemplate name="CompSignalDetails"> <WithParam name="Dir" select="'Tx'"/> </ApplyTemplate> </ContextGoBackToPart> </ForEachInContext> </Template> <Template name="Reqs"> <ForEachInContext name="x" group="Req"> <XElement name="packagedElement"> <!-- XAttribute name="xmi:type" value="uml:Class"/ --> <XAttribute name="xmi:type" value="uml:Class"/> <XAttribute name="xmi:id" value="EAID_#{AncestorHandle}"/> <XAttribute name="name" value="#{Name}"/> </XElement> </ForEachInContext> </Template> <Template name="ReqDependency"> <ForEachInContext name="x" group="Req"> <Variable name="ReqItemId" select="AncestorHandle" as="String"/> <ForEach select="Context:/back-to-part::Reqs"> <Variable name="ReqPartId" select="AncestorHandle" as="String"/> <ForEach select="Context:/owner::/back::SubSecs*/back::Secs"> <XElement name="packagedElement"> <!-- XAttribute name="xmi:type" value="uml:Class"/ --> <XAttribute name="xmi:type" value="uml:Dependency"/> <XAttribute name="xmi:id" value="EAID_#{?$ReqPartId}"/> <XAttribute name="supplier" value="EAID_#{?$ReqItemId}"/> <XAttribute name="client" value="EAID_#{AncestorHandle}"/> </XElement> </ForEach> </ForEach> </ForEachInContext> </Template> <Template name="ExtenderCompSignalAgg"> <Parameter name="CompID" as="String"/> <XElement name="Association"> <XAttribute name="xmi:id" value="EAID_ASS#{AncestorHandle}"/> <XAttribute name="start" value="EAID_#{?$CompID}"/> <DefObj> <XAttribute name="end" value="EAID_#{AncestorHandle}"/> </DefObj> </XElement> </Template> <Template name="ExtenderComp"> <ForEachInContext name="x" group="Comp"> <XElement name="element"> <XAttribute name="xmi:idref" value="EAID_#{AncestorHandle}"/> <XAttribute name="xmi:type" value="uml:Class"/> <XAttribute name="name" value="#{Name}"/> <XAttribute name="scope" value="public"/> <XElement name="model"> <ForEachInContext name="x" group="main"> <XAttribute name="package" value="EAPK_PK#{AncestorHandle}"/> </ForEachInContext> <XAttribute name="ea_eleType" value="element"/> </XElement> <XElement name="properties"> <XAttribute name="isSpecification" value="false"/> <XAttribute name="sType" value="Class"/> <XAttribute name="nType" value="0"/> <XAttribute name="scope" value="public"/> <Choose> <When test="SID='ARAP'"> <XAttribute name="stereotype" value="SWC"/> </When> <Otherwise> <XAttribute name="stereotype" value="SASC"/> </Otherwise> </Choose> <XAttribute name="isRoot" value="false"/> <XAttribute name="isLeaf" value="false"/> <XAttribute name="isAbstract" value="false"/> <XAttribute name="isActive" value="false"/> </XElement> <XElement name="project"> <XAttribute name="author" value="#{Owner.RealName}"/> <XAttribute name="version" value="#{VersionNumber}"/> <XAttribute name="created" value="#{CreationDate}"/> <XAttribute name="modified" value="#{LastChanged}"/> <XAttribute name="status" value="#{Status}"/> </XElement> <XElement name="extendedProperties"> <XAttribute name="tagged" value="0"/> <ForEachInContext name="x" group="main"> <XAttribute name="package_name" value="#{Name}"/> </ForEachInContext> </XElement> <Variable name="Comp" select="AncestorHandle" as="String"/> <XElement name="links"> <!-- Dependency - Requirements --> <ForEach select="Context:/Secs/SubSecs*/part::Reqs"> <XElement name="Dependency"> <XAttribute name="xmi:id" value="EAID_#{AncestorHandle}"/> <DefObj> <XAttribute name="start" value="EAID_#{?$Comp}"/> <XAttribute name="end" value="EAID_#{AncestorHandle}"/> </DefObj> </XElement> </ForEach> <!-- Association - Signal --> <ForEach select="/part::RecSigs"> <ApplyTemplate name="ExtenderCompSignalAgg"> <WithParam name="CompID" select="$Comp"/> </ApplyTemplate> </ForEach> <ForEach select="/part::SendSigs"> <ApplyTemplate name="ExtenderCompSignalAgg"> <WithParam name="CompID" select="$Comp"/> </ApplyTemplate> </ForEach> </XElement> </XElement> </ForEachInContext> </Template> <Template name="ExtenderSignalAss"> <XElement name="Association"> <XAttribute name="xmi:id" value="EAID_ASS#{AncestorHandle}"/> <ContextGoBack> <XAttribute name="start" value="EAID_#{AncestorHandle}"/> </ContextGoBack> <ContextGoForward> <XAttribute name="end" value="EAID_#{AncestorHandle}"/> </ContextGoForward> </XElement> </Template> <Template name="ExtenderSignal"> <ForEachInContext name="x" group="Sig"> <XElement name="element"> <XAttribute name="xmi:idref" value="EAID_#{AncestorHandle}"/> <XAttribute name="xmi:type" value="uml:Signal"/> <XAttribute name="name" value="#{Name}"/> <XAttribute name="scope" value="public"/> <XElement name="model"> <ForEachInContext name="x" group="main"> <XAttribute name="package" value="EAPK_PK#{AncestorHandle}"/> </ForEachInContext> <XAttribute name="ea_eleType" value="element"/> </XElement> <XElement name="properties"> <XAttribute name="isSpecification" value="false"/> <XAttribute name="sType" value="Signal"/> <XAttribute name="nType" value="0"/> <XAttribute name="scope" value="public"/> <XAttribute name="isRoot" value="false"/> <XAttribute name="isLeaf" value="false"/> <XAttribute name="isAbstract" value="false"/> </XElement> <XElement name="project"> <XAttribute name="author" value="#{Owner.RealName}"/> <XAttribute name="version" value="#{VersionNumber}"/> <XAttribute name="created" value="#{CreationDate}"/> <XAttribute name="modified" value="#{LastChanged}"/> <XAttribute name="status" value="#{Status}"/> </XElement> <XElement name="links"> <ForEach select="Context:/back-to-part::RecSigs"> <ApplyTemplate name="ExtenderSignalAss"/> </ForEach> <ForEach select="Context:/back-to-part::SendSigs"> <ApplyTemplate name="ExtenderSignalAss"/> </ForEach> </XElement> </XElement> </ForEachInContext> </Template> <Template name="ExtenderRequirement"> <ForEachInContext name="x" group="Req"> <XElement name="element"> <XAttribute name="xmi:idref" value="EAID_#{AncestorHandle}"/> <XAttribute name="xmi:type" value="uml:Requirement"/> <XAttribute name="name" value="#{Name}"/> <XAttribute name="scope" value="public"/> <XElement name="model"> <ForEachInContext name="x" group="main"> <XAttribute name="package" value="EAPK_PK#{AncestorHandle}"/> </ForEachInContext> <XAttribute name="ea_eleType" value="element"/> </XElement> <XElement name="properties"> <XAttribute name="isSpecification" value="false"/> <XAttribute name="sType" value="Requirement"/> <XAttribute name="nType" value="0"/> <XAttribute name="scope" value="public"/> </XElement> <XElement name="project"> <XAttribute name="author" value="#{Owner.RealName}"/> <XAttribute name="version" value="#{VersionNumber}"/> <XAttribute name="created" value="#{CreationDate}"/> <XAttribute name="modified" value="#{LastChanged}"/> <XAttribute name="status" value="#{Status}"/> </XElement> <XElement name="tags"> <XElement name="tag"> <XAttribute name="xmi:id" value="EAID_A#{AncestorHandle}"/> <XAttribute name="name" value="ReqID"/> <XAttribute name="value" value="#{Attribute:2RQID}"/> <XAttribute name="modelElement" value="EAID_#{AncestorHandle}"/> </XElement> </XElement> <XElement name="links"> <Variable name="ReqItem" select="AncestorHandle" as="String"/> <ForEach select="Context:/back-to-part::Reqs"> <Variable name="ReqPart" select="AncestorHandle" as="String"/> <ForEach select="Context:/owner::/back::SubSecs*/back::Secs"> <XElement name="Dependency"> <XAttribute name="xmi:id" value="EAID_#{?$ReqPart}"/> <XAttribute name="start" value="EAID_#{AncestorHandle}"/> <XAttribute name="end" value="EAID_#{?$ReqItem}"/> </XElement> </ForEach> </ForEach> </XElement> </XElement> </ForEachInContext> </Template> <Template name="ReqConnDetails"> <Parameter name="ReqName" as="String"/> <Parameter name="ReqID" as="String"/> <Parameter name="ConnID" as="String"/> <XElement name="connector"> <XAttribute name="xmi:idref" value="EAID_#{?$ConnID}"/> <XElement name="source"> <XAttribute name="xmi:idref" value="EAID_#{AncestorHandle}"/> <XElement name="model"> <XAttribute name="type" value="Class"/> <XAttribute name="name" value="#{Name}"/> </XElement> <XElement name="role"> <XAttribute name="visibility" value="Public"/> <XAttribute name="targetScope" value="instance"/> </XElement> <XElement name="type"> <XAttribute name="aggregation" value="none"/> <XAttribute name="containment" value="Unspecified"/> </XElement> <XElement name="modifiers"> <XAttribute name="isOrdered" value="false"/> <XAttribute name="changeable" value="none"/> <XAttribute name="isNavigable" value="false"/> </XElement> </XElement> <XElement name="target"> <XAttribute name="xmi:idref" value="EAID_#{?$ReqID}"/> <XElement name="model"> <XAttribute name="type" value="Requirement"/> <XAttribute name="name" value="#{?$ReqName}"/> </XElement> <XElement name="role"> <XAttribute name="visibility" value="Public"/> <XAttribute name="targetScope" value="instance"/> </XElement> <XElement name="type"> <XAttribute name="aggregation" value="shared"/> <XAttribute name="containment" value="Unspecified"/> </XElement> <XElement name="modifiers"> <XAttribute name="isOrdered" value="false"/> <XAttribute name="changeable" value="none"/> <XAttribute name="isNavigable" value="true"/> </XElement> </XElement> <XElement name="properties"> <XAttribute name="ea_type" value="Dependency"/> <XAttribute name="stereotype" value="satisfy"/> <XAttribute name="direction" value="Source -> Destination"/> </XElement> <XElement name="appearance"> <XAttribute name="linemode" value="3"/> <XAttribute name="linecolor" value="-1"/> <XAttribute name="linewidth" value="0"/> <XAttribute name="seqno" value="0"/> <XAttribute name="headStyle" value="0"/> <XAttribute name="lineStyle" value="0"/> </XElement> <XElement name="labels"> <XAttribute name="mb" value=" 
«satisfy»"/> </XElement> <XElement name="extendedProperties"> <XAttribute name="conditional" value="
«satisfy»"/> <XAttribute name="virtualInheritance" value="0"/> </XElement> </XElement> </Template> <Template name="ReqConnectors"> <!-- Dependency --> <ForEachInContext name="x" group="Req"> <Variable name="ReqID" select="AncestorHandle" as="String"/> <Variable name="ReqName" select="Name" as="String"/> <ForEach select="Context:/back-to-part::Reqs"> <Variable name="ConnID" select="AncestorHandle" as="String"/> <ForEach select="Context:/owner::/back::SubSecs*/back::Secs"> <ApplyTemplate name="ReqConnDetails"> <WithParam name="ReqName" select="$ReqName"/> <WithParam name="ReqID" select="$ReqID"/> <WithParam name="ConnID" select="$ConnID"/> </ApplyTemplate> </ForEach> </ForEach> </ForEachInContext> </Template> <Template name="SignalConnectorDetails"> <Parameter name="Dir" as="String"/> <XElement name="connector"> <XAttribute name="xmi:idref" value="EAID_ASS#{AncestorHandle}"/> <ContextGoBack> <XElement name="source"> <XAttribute name="xmi:idref" value="EAID_#{AncestorHandle}"/> <XElement name="model"> <XAttribute name="type" value="Class"/> <XAttribute name="name" value="#{Name}"/> </XElement> <XElement name="role"> <XAttribute name="name" value="#{?$Dir}"/> <XAttribute name="visibility" value="Public"/> <XAttribute name="targetScope" value="instance"/> </XElement> <XElement name="type"> <XAttribute name="aggregation" value="none"/> <XAttribute name="containment" value="Unspecified"/> </XElement> <XElement name="modifiers"> <XAttribute name="isOrdered" value="false"/> <XAttribute name="changeable" value="none"/> <XAttribute name="isNavigable" value="false"/> </XElement> </XElement> </ContextGoBack> <ContextGoForward> <XElement name="target"> <XAttribute name="xmi:idref" value="EAID_#{AncestorHandle}"/> <XElement name="model"> <XAttribute name="type" value="Signal"/> <XAttribute name="name" value="#{Name}"/> </XElement> <XElement name="role"> <XAttribute name="visibility" value="Public"/> <XAttribute name="targetScope" value="instance"/> </XElement> <XElement name="type"> <XAttribute name="aggregation" value="none"/> <XAttribute name="containment" value="Unspecified"/> </XElement> <XElement name="modifiers"> <XAttribute name="isOrdered" value="false"/> <XAttribute name="changeable" value="none"/> <XAttribute name="isNavigable" value="false"/> </XElement> </XElement> </ContextGoForward> <XElement name="properties"> <XAttribute name="ea_type" value="Association"/> <XAttribute name="direction" value="Source -> Destination"/> </XElement> <XElement name="appearance"> <XAttribute name="linemode" value="3"/> <XAttribute name="linecolor" value="-1"/> <XAttribute name="linewidth" value="0"/> <XAttribute name="seqno" value="0"/> <XAttribute name="headStyle" value="0"/> <XAttribute name="lineStyle" value="0"/> </XElement> <XElement name="labels"> <XAttribute name="lt" value="+#{?$Dir}"/> </XElement> <XElement name="extendedProperties"> <XAttribute name="virtualInheritance" value="0"/> </XElement> </XElement> </Template> <Template name="SignalConnector"> <ForEachInContext name="x" group="Sig"> <ForEach select="Context:/back-to-part::RecSigs"> <ApplyTemplate name="SignalConnectorDetails"> <WithParam name="Dir" select="'Rx'"/> </ApplyTemplate> </ForEach> <ForEach select="Context:/back-to-part::SendSigs"> <ApplyTemplate name="SignalConnectorDetails"> <WithParam name="Dir" select="'Tx'"/> </ApplyTemplate> </ForEach> </ForEachInContext> </Template> <XElement name="xmi:Documentation"> <XAttribute name="exporter" value="Enterprise Architect"/> <XAttribute name="exporterVersion" value="6.5"/> </XElement> <XElement name="uml:Model"> <XAttribute name="xmi:type" value="uml:Model"/> <XAttribute name="name" value="EA_Model"/> <XElement name="packagedElement"> <XAttribute name="xmi:type" value="uml:Package"/> <XAttribute name="xmi:id" value="EAPK_PK#{AncestorHandle}"/> <XAttribute name="name" value="#{Name}"/> <ApplyTemplate name="FunctionClass"/> <ApplyTemplate name="SignalClass"/> <ApplyTemplate name="CompSignalAssociation"/> <ApplyTemplate name="Reqs"/> <ApplyTemplate name="ReqDependency"/> </XElement> </XElement> <XElement name="xmi:Extension"> <XAttribute name="extender" value="Enterprise Architect"/> <XAttribute name="extenderID" value="6.5"/> <XElement name="elements"> <ApplyTemplate name="ExtenderComp"/> <ApplyTemplate name="ExtenderSignal"/> <ApplyTemplate name="ExtenderRequirement"/> </XElement> <!-- Connectors --> <XElement name="connectors"> <ApplyTemplate name="ReqConnectors"/> <ApplyTemplate name="SignalConnector"/> </XElement> </XElement> <!-- Components --> <ForEachInContext name="x" group="Comp"> <Choose> <When test="SID='ARAP'"> <XElement name="thecustomprofile:SWC"> <XAttribute name="base_Class" value="EAID_#{AncestorHandle}"/> </XElement> </When> <Otherwise> <XElement name="thecustomprofile:SASC"> <XAttribute name="base_Class" value="EAID_#{AncestorHandle}"/> </XElement> </Otherwise> </Choose> </ForEachInContext> <!-- Requirement Connections--> <ForEachInContext name="x" group="Req"> <ForEach select="Context:/back-to-part::Reqs"> <XElement name="sysml:satisfy"> <XAttribute name="base_Class" value="EAID_#{AncestorHandle}"/> </XElement> </ForEach> </ForEachInContext> <!-- Requirements --> <ForEachInContext name="x" group="Req"> <XElement name="thecustomprofile:Id"> <XAttribute name="base_Class" value="EAID_#{AncestorHandle}"/> <XAttribute name="ReqID" value="#{Attribute:2RQID}"/> </XElement> </ForEachInContext> </XDocument>