Hello, I'm currently developing a script that imports XML file that contains a sequence diagram create in EA.
Has any script being made with this purpose or do you have any examples?
Thanks
Paulo
Hello Paulo,
there are few forum entries that deal with XML import, for example https://medini.freshdesk.com/support/discussions/topics/1000110231. There are others that deal with import from EA/Cameo XMI files. I am not sure which one helps as I am unaware how you may have created that file from EA. Note that there are also articles that deal with EAP imports. In addition we have the "Scripted Importer" framework.
Happy Scripting
Jan
Hello thanks for your answer. Basically so far I have this script:
// $EXPERIMENTAL$ $STRICT_MODE$// EA Sequence Diagram Importer for Medini// Note: Sequence Diagrams must be created manually;// this script only creates model elements in a containerif (!bind) throw "Extended API required";var XML = load(".lib/xml.js");load(".lib/factory.js");load(".lib/ui.js");var issues = [];function report(msg) { issues.push(msg); console.error(msg);}// Helper function: get direct child elements by tag namefunction getChildren(node, tag) { var result = []; if (!node) return result; for (var c = node.firstChild; c != null; c = c.nextSibling) { if (c.nodeType === 1 && (tag === "*" || c.nodeName === tag)) { result.push(c); } } return result;}function main() { // 1️ Mandatory selection of a SysML Package if (!selection || selection.length === 0) return "Please select a valid SysML Package."; var sel = selection[0]; if (!(sel instanceof Metamodel.sysml.SysMLContainerPackage)) { return "Invalid selection! Please select a SysML Package."; } // 2️ Create ImportedSequences container inside the selected package var container = Factory.createElement( sel, Metamodel.sysml.SysMLContainerPackage ); container.name = "ImportedSequences"; // 3 Open XML file var file = openFile([""]); if (!file) return "No file selected"; var doc = XML.parse(file); var xmiRoot = doc.getDocumentElement(); if (!xmiRoot) return "Invalid XML document"; // 4️ Create Actors (EA: UML:Actor) var actorsMap = {}; var packages = xmiRoot.getElementsByTagName("UML:Package"); for (var p = 0; p < packages.getLength(); p++) { var pkg = packages.item(p); var actorNodes = getChildren(pkg, "UML:Actor"); actorNodes.forEach(function (actor) { var id = actor.getAttribute("xmi.id"); var name = actor.getAttribute("name"); var actorEl = Factory.createElement( container, Metamodel.sysml.SysMLActor ); actorEl.name = name; actorEl.mediniIdentifier = id; actorsMap[id] = actorEl; }); } // 5️ Create Lifelines (ClassifierRoles) var lifelinesMap = {}; var interactions = xmiRoot.getElementsByTagName("UML:Interaction"); for (var i = 0; i < interactions.getLength(); i++) { var inter = interactions.item(i); var ownedElements = getChildren(inter, "UML:Namespace.ownedElement"); ownedElements.forEach(function (owned) { var roles = getChildren(owned, "UML:ClassifierRole"); roles.forEach(function (role) { var id = role.getAttribute("xmi.id"); var name = role.getAttribute("name"); var lifeline = Factory.createElement( container, Metamodel.sysml.SysMLActor ); lifeline.name = name; lifeline.mediniIdentifier = id; lifeline.TaggedValues.add("seqno", "0"); lifelinesMap[id] = lifeline; }); }); // 6️⃣ Create messages (as Traces) var msgContainers = getChildren(inter, "UML:Interaction.message"); msgContainers.forEach(function (msgCont) { var msgs = getChildren(msgCont, "UML:Message"); msgs.forEach(function (msg) { var sender = lifelinesMap[msg.getAttribute("sender")] || actorsMap[msg.getAttribute("sender")]; var receiver = lifelinesMap[msg.getAttribute("receiver")] || actorsMap[msg.getAttribute("receiver")]; if (!sender || !receiver) { report( "Sender or receiver not found for message: " + msg.getAttribute("xmi.id") ); return; } // Create Trace representing the message var trace = Factory.createRelation( sender, receiver, Metamodel.traceability.Trace ); var taggedValues = getChildren( msg, "UML:ModelElement.taggedValue" ); var seqno = taggedValues.length > 0 ? taggedValues[0].getAttribute("seqno") || "0" : "0"; trace.TaggedValues.add("seqno", seqno); }); }); } // 7️ Final report if (issues.length) { alert( "Import completed with issues:\n" + issues.join("\n") ); } else { alert( "Import completed successfully!\n" + "Now create a Sequence Diagram manually and drag the elements from the container." ); } return "Done";}main();
I don't have much experience with javascript or any scripting language.
Is it true that we can not import a sequence diagram but only its elements in a container?
This is XML I'm trying to import, its simple sequence diagram exported from EA.
<?xml version="1.0" encoding="windows-1252" standalone="no" ?><XMI xmi.version="1.1" xmlns:UML="omg.org/UML1.3" timestamp="2026-01-15 15:50:26"> <XMI.header> <XMI.documentation> <XMI.exporter>Enterprise Architect</XMI.exporter> <XMI.exporterVersion>2.5</XMI.exporterVersion> <XMI.exporterID>1623</XMI.exporterID> </XMI.documentation> </XMI.header> <XMI.content> <UML:Model name="EA Model" xmi.id="MX_EAID_67DADA71_1571_47c9_993C_FE2177E83AEC"> <UML:Namespace.ownedElement> <UML:Class name="EARootClass" xmi.id="EAID_11111111_5487_4080_A7F4_41526CB0AA00" isRoot="true" isLeaf="false" isAbstract="false"/> <UML:Package name="Sequence" xmi.id="EAPK_67DADA71_1571_47c9_993C_FE2177E83AEC" isRoot="false" isLeaf="false" isAbstract="false" visibility="public"> <UML:ModelElement.taggedValue> <UML:TaggedValue tag="parent" value="EAPK_D459E852_2DA0_4381_941C_ACB189FDACF0"/> <UML:TaggedValue tag="created" value="2026-01-15 15:49:10"/> <UML:TaggedValue tag="modified" value="2026-01-15 15:49:10"/> <UML:TaggedValue tag="iscontrolled" value="0"/> <UML:TaggedValue tag="version" value="1.0"/> <UML:TaggedValue tag="isprotected" value="0"/> <UML:TaggedValue tag="usedtd" value="0"/> <UML:TaggedValue tag="logxml" value="0"/> <UML:TaggedValue tag="phase" value="1.0"/> <UML:TaggedValue tag="status" value="Proposed"/> <UML:TaggedValue tag="author" value="TE576589"/> <UML:TaggedValue tag="complexity" value="1"/> <UML:TaggedValue tag="ea_stype" value="Public"/> <UML:TaggedValue tag="tpos" value="0"/> <UML:TaggedValue tag="gentype" value="C"/> </UML:ModelElement.taggedValue> <UML:Namespace.ownedElement> <UML:Actor name="Actor1" xmi.id="EAID_4C60CAD0_C3A1_4c2b_8A15_B3AE4CFF818D" visibility="public" namespace="EAPK_67DADA71_1571_47c9_993C_FE2177E83AEC" isRoot="false" isLeaf="false" isAbstract="false"> <UML:ModelElement.taggedValue> <UML:TaggedValue tag="isSpecification" value="false"/> <UML:TaggedValue tag="ea_stype" value="Actor"/> <UML:TaggedValue tag="ea_ntype" value="0"/> <UML:TaggedValue tag="version" value="1.0"/> <UML:TaggedValue tag="isActive" value="false"/> <UML:TaggedValue tag="package" value="EAPK_67DADA71_1571_47c9_993C_FE2177E83AEC"/> <UML:TaggedValue tag="date_created" value="2026-01-15 15:50:03"/> <UML:TaggedValue tag="date_modified" value="2026-01-15 15:50:03"/> <UML:TaggedValue tag="gentype" value="<none>"/> <UML:TaggedValue tag="tagged" value="0"/> <UML:TaggedValue tag="package_name" value="Sequence"/> <UML:TaggedValue tag="phase" value="1.0"/> <UML:TaggedValue tag="author" value="TE576589"/> <UML:TaggedValue tag="complexity" value="1"/> <UML:TaggedValue tag="status" value="Proposed"/> <UML:TaggedValue tag="tpos" value="0"/> <UML:TaggedValue tag="ea_localid" value="10270"/> <UML:TaggedValue tag="ea_eleType" value="element"/> <UML:TaggedValue tag="style" value="BackColor=-1;BorderColor=-1;BorderWidth=-1;FontColor=-1;VSwimLanes=1;HSwimLanes=1;BorderStyle=0;"/> </UML:ModelElement.taggedValue> </UML:Actor> <UML:Collaboration xmi.id="EAID_67DADA71_1571_47c9_993C_FE2177E83AEC_Collaboration" name="Collaborations"> <UML:Namespace.ownedElement> <UML:ClassifierRole name="Boundary1" xmi.id="EAID_E7F71726_940E_4f41_84F2_DA72C2A71B2E" visibility="public" base="EAID_11111111_5487_4080_A7F4_41526CB0AA00"> <UML:ModelElement.stereotype> <UML:Stereotype name="boundary"/> </UML:ModelElement.stereotype> <UML:ModelElement.taggedValue> <UML:TaggedValue tag="isAbstract" value="false"/> <UML:TaggedValue tag="isSpecification" value="false"/> <UML:TaggedValue tag="ea_stype" value="Sequence"/> <UML:TaggedValue tag="ea_ntype" value="0"/> <UML:TaggedValue tag="version" value="1.0"/> <UML:TaggedValue tag="isActive" value="false"/> <UML:TaggedValue tag="package" value="EAPK_67DADA71_1571_47c9_993C_FE2177E83AEC"/> <UML:TaggedValue tag="date_created" value="2026-01-15 15:50:05"/> <UML:TaggedValue tag="date_modified" value="2026-01-15 15:50:05"/> <UML:TaggedValue tag="gentype" value="<none>"/> <UML:TaggedValue tag="tagged" value="0"/> <UML:TaggedValue tag="package_name" value="Sequence"/> <UML:TaggedValue tag="phase" value="1.0"/> <UML:TaggedValue tag="author" value="TE576589"/> <UML:TaggedValue tag="complexity" value="1"/> <UML:TaggedValue tag="status" value="Proposed"/> <UML:TaggedValue tag="stereotype" value="boundary"/> <UML:TaggedValue tag="tpos" value="0"/> <UML:TaggedValue tag="ea_localid" value="10271"/> <UML:TaggedValue tag="ea_eleType" value="element"/> <UML:TaggedValue tag="style" value="BackColor=-1;BorderColor=-1;BorderWidth=-1;FontColor=-1;VSwimLanes=1;HSwimLanes=1;BorderStyle=0;"/> <UML:TaggedValue tag="$ea_xref_property" value="$XREFPROP=$XID={52163939-93DE-4b3b-AA45-898E6B86DE1C}$XID;$NAM=Stereotypes$NAM;$TYP=element property$TYP;$VIS=Public$VIS;$PAR=0$PAR;$DES=@STEREO;Name=boundary;FQName=EAUML::boundary;@ENDSTEREO;$DES;$CLT={E7F71726-940E-4f41-84F2-DA72C2A71B2E}$CLT;$SUP=<none>$SUP;$ENDXREF;"/> </UML:ModelElement.taggedValue> </UML:ClassifierRole> </UML:Namespace.ownedElement> <UML:Collaboration.interaction> <UML:Interaction xmi.id="EAID_67DADA71_1571_47c9_993C_FE2177E83AEC_INT" name="EAID_67DADA71_1571_47c9_993C_FE2177E83AEC_INT"> <UML:Interaction.message> <UML:Message xmi.id="EAID_57D0B368_44BB_4c75_9F6C_D6EBF8A8EEDB" visibility="public" sender="EAID_4C60CAD0_C3A1_4c2b_8A15_B3AE4CFF818D" receiver="EAID_E7F71726_940E_4f41_84F2_DA72C2A71B2E"> <UML:ModelElement.taggedValue> <UML:TaggedValue tag="style" value="1"/> <UML:TaggedValue tag="ea_type" value="Sequence"/> <UML:TaggedValue tag="direction" value="Source -> Destination"/> <UML:TaggedValue tag="linemode" value="1"/> <UML:TaggedValue tag="linecolor" value="-1"/> <UML:TaggedValue tag="linewidth" value="0"/> <UML:TaggedValue tag="seqno" value="1"/> <UML:TaggedValue tag="headStyle" value="0"/> <UML:TaggedValue tag="lineStyle" value="0"/> <UML:TaggedValue tag="privatedata1" value="Synchronous"/> <UML:TaggedValue tag="privatedata2" value="retval=void;"/> <UML:TaggedValue tag="privatedata3" value="Call"/> <UML:TaggedValue tag="privatedata4" value="0"/> <UML:TaggedValue tag="ea_localid" value="10057"/> <UML:TaggedValue tag="ea_sourceName" value="Actor1"/> <UML:TaggedValue tag="ea_targetName" value="Boundary1"/> <UML:TaggedValue tag="ea_sourceType" value="Actor"/> <UML:TaggedValue tag="ea_targetType" value="Sequence"/> <UML:TaggedValue tag="ea_sourceID" value="10270"/> <UML:TaggedValue tag="ea_targetID" value="10271"/> <UML:TaggedValue tag="src_visibility" value="Public"/> <UML:TaggedValue tag="src_isOrdered" value="false"/> <UML:TaggedValue tag="src_targetScope" value="instance"/> <UML:TaggedValue tag="src_changeable" value="none"/> <UML:TaggedValue tag="src_isNavigable" value="false"/> <UML:TaggedValue tag="src_containment" value="Unspecified"/> <UML:TaggedValue tag="src_style" value="Union=0;Derived=0;AllowDuplicates=0;Owned=0;Navigable=Non-Navigable;"/> <UML:TaggedValue tag="dst_visibility" value="Public"/> <UML:TaggedValue tag="dst_aggregation" value="0"/> <UML:TaggedValue tag="dst_isOrdered" value="false"/> <UML:TaggedValue tag="dst_targetScope" value="instance"/> <UML:TaggedValue tag="dst_changeable" value="none"/> <UML:TaggedValue tag="dst_isNavigable" value="true"/> <UML:TaggedValue tag="dst_containment" value="Unspecified"/> <UML:TaggedValue tag="dst_style" value="Union=0;Derived=0;AllowDuplicates=0;Owned=0;Navigable=Navigable;"/> <UML:TaggedValue tag="privatedata5" value="SX=0;SY=0;EX=0;EY=0;$LLB=;LLT=;LMT=;LMB=;LRT=;LRB=;IRHS=;ILHS=;"/> <UML:TaggedValue tag="sequence_points" value="PtStartX=180;PtStartY=-135;PtEndX=300;PtEndY=-135;"/> <UML:TaggedValue tag="stateflags" value="Activation=0;ExtendActivationUp=0;"/> <UML:TaggedValue tag="virtualInheritance" value="0"/> <UML:TaggedValue tag="diagram" value="EAID_8C377CC4_8D1F_418d_847C_E51F9AD249E0"/> </UML:ModelElement.taggedValue> </UML:Message> </UML:Interaction.message> </UML:Interaction> </UML:Collaboration.interaction> </UML:Collaboration> </UML:Namespace.ownedElement> </UML:Package> </UML:Namespace.ownedElement> </UML:Model> <UML:Diagram name="Sequence" xmi.id="EAID_8C377CC4_8D1F_418d_847C_E51F9AD249E0" diagramType="SequenceDiagram" owner="EAPK_67DADA71_1571_47c9_993C_FE2177E83AEC" toolName="Enterprise Architect 2.5"> <UML:ModelElement.taggedValue> <UML:TaggedValue tag="version" value="1.0"/> <UML:TaggedValue tag="author" value="TE576589"/> <UML:TaggedValue tag="created_date" value="2026-01-15 15:50:00"/> <UML:TaggedValue tag="modified_date" value="2026-01-15 15:50:14"/> <UML:TaggedValue tag="package" value="EAPK_67DADA71_1571_47c9_993C_FE2177E83AEC"/> <UML:TaggedValue tag="type" value="Sequence"/> <UML:TaggedValue tag="swimlanes" value="locked=false;orientation=0;width=0;inbar=false;names=false;color=-1;bold=false;fcol=0;tcol=-1;ofCol=-1;ufCol=-1;hl=1;ufh=0;hh=0;cls=0;bw=0;hli=0;bro=0;SwimlaneFont=lfh:-10,lfw:0,lfi:0,lfu:0,lfs:0,lfface:Calibri,lfe:0,lfo:0,lfchar:1,lfop:0,lfcp:0,lfq:0,lfpf=0,lfWidth=0;"/> <UML:TaggedValue tag="matrixitems" value="locked=false;matrixactive=false;swimlanesactive=true;kanbanactive=false;width=1;clrLine=0;"/> <UML:TaggedValue tag="ea_localid" value="1097"/> <UML:TaggedValue tag="EAStyle" value="ShowPrivate=1;ShowProtected=1;ShowPublic=1;HideRelationships=0;Locked=0;Border=1;HighlightForeign=1;PackageContents=1;SequenceNotes=0;ScalePrintImage=0;PPgs.cx=0;PPgs.cy=0;DocSize.cx=791;DocSize.cy=1134;ShowDetails=0;Orientation=P;Zoom=100;ShowTags=0;OpParams=1;VisibleAttributeDetail=0;ShowOpRetType=1;ShowIcons=1;CollabNums=0;HideProps=0;ShowReqs=0;ShowCons=0;PaperSize=9;HideParents=0;UseAlias=0;HideAtts=0;HideOps=0;HideStereo=0;HideElemStereo=0;ShowTests=0;ShowMaint=0;ConnectorNotation=UML 2.1;ExplicitNavigability=0;ShowShape=1;AllDockable=0;AdvancedElementProps=1;AdvancedFeatureProps=1;AdvancedConnectorProps=1;m_bElementClassifier=1;SPT=1;ShowNotes=0;SuppressBrackets=0;SuppConnectorLabels=0;PrintPageHeadFoot=0;ShowAsList=0;"/> <UML:TaggedValue tag="styleex" value="SaveTag=5F80A71E;ExcludeRTF=0;DocAll=0;HideQuals=0;AttPkg=1;ShowTests=0;ShowMaint=0;SuppressFOC=0;INT_ARGS=;INT_RET=;INT_ATT=;SeqTopMargin=50;MatrixActive=0;SwimlanesActive=1;KanbanActive=0;MatrixLineWidth=1;MatrixLineClr=0;MatrixLocked=0;TConnectorNotation=UML 2.1;TExplicitNavigability=0;AdvancedElementProps=1;AdvancedFeatureProps=1;AdvancedConnectorProps=1;m_bElementClassifier=1;SPT=1;MDGDgm=;STBLDgm=;ShowNotes=0;VisibleAttributeDetail=0;ShowOpRetType=1;SuppressBrackets=0;SuppConnectorLabels=0;PrintPageHeadFoot=0;ShowAsList=0;SuppressedCompartments=;Theme=:119;"/> <UML:TaggedValue tag="persistentstyle" value="DGS=On=0:CNT=8:W=120:H=40:SG=0:SGH=0:AEB=0:;AR=0;DCL=0;orientation=0;width=0;inbar=false;names=false;color=-1;bold=false;fcol=0;tcol=-1;ofCol=-1;ufCol=-1;hl=1;ufh=0;hh=0;cls=0;bw=0;hli=0;bro=0;SwimlaneFont=lfh:-10,lfw:0,lfi:0,lfu:0,lfs:0,lfface:Calibri,lfe:0,lfo:0,lfchar:1,lfop:0,lfcp:0,lfq:0,lfpf=0,lfWidth=0;;orientation=0;width=0;inbar=false;names=false;color=-1;bold=false;fcol=0;tcol=-1;ofCol=-1;ufCol=-1;hl=1;ufh=0;hh=0;cls=0;bw=0;hli=0;bro=0;SwimlaneFont=lfh:-10,lfw:0,lfi:0,lfu:0,lfs:0,lfface:Calibri,lfe:0,lfo:0,lfchar:1,lfop:0,lfcp:0,lfq:0,lfpf=0,lfWidth=0;;Swimlanes=locked=false;orientation=0;width=0;inbar=false;names=false;color=-1;bold=false;fcol=0;tcol=-1;ofCol=-1;ufCol=-1;hl=1;ufh=0;hh=0;cls=0;bw=0;hli=0;bro=0;SwimlaneFont=lfh:-10,lfw:0,lfi:0,lfu:0,lfs:0,lfface:Calibri,lfe:0,lfo:0,lfchar:1,lfop:0,lfcp:0,lfq:0,lfpf=0,lfWidth=0;;"/> </UML:ModelElement.taggedValue> <UML:Diagram.element> <UML:DiagramElement geometry="Left=280;Top=50;Right=330;Bottom=165;" subject="EAID_E7F71726_940E_4f41_84F2_DA72C2A71B2E" seqno="1" style="DUID=815B17C0;"/> <UML:DiagramElement geometry="Left=130;Top=50;Right=220;Bottom=165;" subject="EAID_4C60CAD0_C3A1_4c2b_8A15_B3AE4CFF818D" seqno="2" style="DUID=A266820F;"/> <UML:DiagramElement geometry="SX=0;SY=0;EX=0;EY=0;Path=;" subject="EAID_57D0B368_44BB_4c75_9F6C_D6EBF8A8EEDB" style=";Hidden=0;"/> </UML:Diagram.element> </UML:Diagram> </XMI.content> <XMI.difference/> <XMI.extensions xmi.extender="Enterprise Architect 2.5"/></XMI>
the script looks good for a start and the approach is feasible as well. I quickly tried to use our "scripted importer" way of doing things but the file content could not be loaded, there might be multiple reasons, one is that internally the locader expects UML2 while this here is flagged UML1.3? But might be other reasons.
You can also create diagrams in medini wih a script and drag elements on certain positions on the diagram just search for those keywords and find a few articles from usesr who created diagrams and content.
But you would need to extract the diagram infromation from the EA tags as it seems, quite cumbersome I guess.
Alternative would be to save the content into an EAP file and import from there if XML/XMI is not your favorite, you ma ytry that.
The diagram stuff though wold not be any different.
It looks EA exported XML with UML2.
Can you give it a try to this xml simple code with scripted importer?
<?xml version="1.0" encoding="UTF-8"?><xmi:XMI xmlns:xmi="http://schema.omg.org/spec/XMI/2.1" xmlns:uml="http://schema.omg.org/spec/UML/2.1" xmi:version="2.1"> <uml:Model xmi:type="uml:Model" xmi:id="MODEL_1" name="TestModel"> <packagedElement xmi:type="uml:Package" xmi:id="PKG_1" name="Sequence"> <!-- Actors --> <packagedElement xmi:type="uml:Actor" xmi:id="A1" name="Actor1"/> <packagedElement xmi:type="uml:Actor" xmi:id="A2" name="Actor2"/> <!-- Collaboration --> <packagedElement xmi:type="uml:Collaboration" xmi:id="C1" name="Collaboration1"> <ownedBehavior xmi:type="uml:Interaction" xmi:id="I1" name="Interaction1"> <!-- Lifelines --> <lifeline xmi:type="uml:Lifeline" xmi:id="L1" name="Actor1Role" represents="A1"/> <lifeline xmi:type="uml:Lifeline" xmi:id="L2" name="Actor2Role" represents="A2"/> <!-- Message --> <message xmi:type="uml:Message" xmi:id="M1" name="Message1" sendEvent="L1" receiveEvent="L2"/> </ownedBehavior> </packagedElement> </packagedElement> </uml:Model></xmi:XMI>
How can I have access to this scripted importer?
Hi Paulo,
sorry I was OOO for a few days. Anyway, the scripted importer is always part of the tool you just have to enable it in the preferences, its still beta. Open "Preferences -> Integrations -> Scripted Importers.
Once done, you find "Import -> Using a script" at most packages. The wizard requires you to specify an input type, an input file or project document and a script that doe sthe transformation job.
I have a sample transformer script for an XMI expot from Winchill modeler, you may try and adopt it.