Author Topic: Visio UML to Sparx (XMI)  (Read 2334 times)


  • EA Novice
  • *
  • Posts: 16
  • Karma: +0/-0
    • View Profile
Visio UML to Sparx (XMI)
« on: March 11, 2004, 03:42:01 pm »
I found this tool that will create XMI files from Visio UML diagrams (used by many .NET developers as Visio comes with the Enterprise Architect version).

With the XMI you can use the 'Import Package from XMI' feature.

We used it and switched to Sparx as your tool is much better for our needs. Here is where to find the XMI Generator:

Here is the article:

UML to XMI Export Functionality
Microsoft Corporation

February 2002

Applies to:
  Microsoft Visio 2002 Professional
  Microsoft Visual Studio .NET Enterprise Architect (Visio for Enterprise Architects)

Summary: Learn how the XMI Export download helps developers to access information from a Visio UML model by exporting it to an XML file. (4 printed pages)

Download Xmiexport.exe.

User Scenario
Availability and Usage
Installing the XMI Export Facility
Building and Executing the Sample Visio Add-on

This article describes the UML to XMI export functionality that has been added to the Visio UML Solution. Since the UML Solution in Microsoft® Visio® Professional 2002 and Visio for Enterprise Architects (a component of Microsoft® Visual Studio® .NET Enterprise Architect) does not expose an object model API through which UML model elements can be accessed, the export functionality is provided through a separate DLL. The following user scenario describes how a developer can access and use information from a UML model in another application.

User Scenario
A developer wants to write an application that uses information such as class, attribute, or operation names from a UML model that was created with the Visio Professional UML Solution, available from Visio Professional or Visio for Enterprise Architects.

Since the UML Solution does not expose an object model API through which UML model elements can be accessed, the export functionality is provided in a separate DLL (XMIExport.dll). The developer can invoke the XMI Export component and export most of the information contained in static structure, component, and deployment diagrams in an XML file that is compliant with the XMI standard .

The third party application can then parse the XML file using standard techniques like DOM or SAX to access the desired data from the UML model. The DTD file uml.dtd is needed in order to validate and view the XML file, and can be downloaded from the OMG Web site. The supported UML diagrams are class (static structure) diagram (most elements), component diagram (component element), and deployment diagram (node element).

For example, the following UML class (created on a static structure diagram in Visio) will be exported to the corresponding XMI files shown below (note that only a fragment of the XML file is shown).

+interestRate() : float
+calculate(inout amount : double) : double

  <Foundation.Core.ModelElement.visibility xmi.value="public" />
  <Foundation.Core.GeneralizableElement.isRoot xmi.value="false" />
  <Foundation.Core.GeneralizableElement.isLeaf xmi.value="false" />
  <Foundation.Core.GeneralizableElement.isAbstract xmi.value="false" />
  <Foundation.Core.Class.isActive xmi.value="false" />

  <Foundation.Core.ModelElement.visibility xmi.value="private" />
  <Foundation.Core.Feature.ownerScope xmi.value="instance" />

  <Foundation.Core.ModelElement.visibility xmi.value="public" />
  <Foundation.Core.Feature.ownerScope xmi.value="instance" />
  <Foundation.Core.BehavioralFeature.isQuery xmi.value="false" />
  <Foundation.Core.Operation.specification />
  <Foundation.Core.Operation.isPolymorphic xmi.value="false" />
  <Foundation.Core.Operation.concurrency xmi.value="sequential" />

Availability and Usage
The XMI Export functionality is available only through Visio Automation by invoking the Run command in the Visio API.

To access the XMI export functionality, use the Run API of the Visio add-on component. The following two parameters must be supplied to the Run command:

Parameter Description
Visio UML Solution recognizes the 400 command as the XMI export function
This parameter specifies the file where the XMI output will be written. The file name must be double-quote delimited. No blanks are allowed between the "=" and the file name. The file is created if it does not exist. An existing file will be overwritten.

For example, in Visual C++, the API returns VAORC_SUCCESS if the export succeeds.

Note   The sample code files accompanying the XMIExport.dll in the download demonstrate how to invoke the XMI Export functionality of the Visio UML Solution from a Visio add-on. The add-on is built using Microsoft® Visual C++® in Visual Studio .NET.
Installing the XMI Export Facility
To install the XMI export facility, copy the XMIExport.dll file to the Visio DLL folder named <VisioInstallationPath>\DLL.

Building and Executing the Sample Visio Add-on

Load the sample Visual Studio solution file VisioUmlAddon in Visual Studio .NET and build the solution; the result is a file named VisioUmlAddon.vsl in the Debug folder (created by default in the folder where the VS solution file is).
Copy the VisioUmlAddOn.vsl file to the folder <VisioInstallationPath>\1033\Solutions\Visio Extras.
Create a UML static structure diagram and add elements to it. From the Visio menu, select Tools, point to Macros, and then click Visio Extras. A new menu item, XMI export, will appear. Select it and choose a file name from the Save As dialog box. A message is displayed (Export to XMI succeeded) after completion of the export process. Browse to the exported .xmi file.

To open the file in Microsoft® Internet Explorer, place the DTD file uml.dtd into the same folder as the saved .xmi file.

Damon Carr

Damon Carr, Chief Technologist