XMI Export Sample


Steve Cook, a long time architect on my team, has made available a sample that shows how to access the UML meta data in Visual Studio’s  new UML project system and export that data into the OMG’s XMI data format. XMI is the OMG standard used to describe UML meta data for exchange between various tool vendors.

In Visual Studio 2010 Ultimate, we have the ability to import XMI ( via the Visualization and Modeling Feature Pack ), but we didn’t get XMI export into the feature pack.

If you are interested in this sample, here are the steps you need to do to take it for a test drive:

 

  1. Download the sample
    Once downloaded, double check to see if you need to unblock the zip file. Better to do this now if needed, rather than all the extracted files. Just right click on the XmiExporterSample.zip file and select “Properties”:
    SNAGHTML19cfffc9If you don’t see the “Unblock” button, then you can safely skip this step.
  2. Extract the zip file to your favorite directory and double-click on the XmiExporterSample.sln file.
    This will launch VS for you. If you are presented with any dialogs about version control, you can safely ignore. If you are asked, choose to permanently remove the version control settings from the solution.
  3. Right click on the XmiExport project in the Solution Explorer and select “Set as StartUp Project”
    Also, if you are running a x64 bit version of windows, you will need to go into the project settings to point at the appropriate version of Visual Studio. Right click on the XmiExport project, select Properties, click on the Debug tab, and make sure you are pointing at the correct DevEnv.exe. On my machine, that happens to be here : “C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe”
  4. Set the “Solution Configuration” to be Release
    image
  5. Rebuild your solution
  6. Double click the Microsoft.Example.XmiExporter.vsix file
    In the output directory for the XmiExporter project ( XMIExporter\bin\Release ), you’ll find a Microsoft.Example.XmiExporter.vsix file. Double clicking that vsix will install the XmiExport sample into your Visual Studio instance.
    SNAGHTML19de1eae 
  7. Restart Visual Studio, create a new UML modeling project, create a UML class diagram, and notice the new “Export XMI…” menu item when right-clicking in the background of the diagram!
    Drop some elements on the diagram so you have something to export.
  8. Select “Export XMI…”
    A dialog will popup asking where you want the resulting XMI file to go.

 

And that’s it!

The great thing about providing this as a sample is you can jump into the source to see how to get access at all the UML meta data in your UML Modeling projects. To start, reopen the XmiExporterSample and open the XmiExportCommand.cs file. Set a break in the Execute method…

Hope that helps,

Cameron


Comments (7)

  1. Pat McGovern says:

    Cameron,

    Has anyone else been able to load this sln file? I've been getting an error saying it can't read the csproj files.

    Thanks,

    Pat

  2. Yeah, I haven't heard of any problems, and a number of folks on the forums have opened and run it to the point they are reporting bugs! 🙂

    Follow up with me offline Pat and let me know what your exact error is…

  3. John Calvert says:

    The VS2010 native XMI import capability only supports a subset of the diagrams available in VS2010, namely sequence diagrams, class diagrams, and use case diagrams, as per msdn.microsoft.com/…/ff657797.aspx. What does does this export sample support?

  4. It will export all the meta-data we currently support in order to drive the functionality you see in the shipping diagrams we support out of the box ( all the meta-data supporting the five UML diagrams currently in the box = Use Case, Sequence, Activity, Component, and Class ).

  5. wanglipeng says:

    good

  6. Lisa says:

    How did you get this to build outside of MSFT build environment? There are so many references to MSFT internal files.

  7. Lisa – it does not reference anything internal.  

    Have you installed the VSVMSDK? archive.msdn.microsoft.com/vsvmsdk