Friday, March 5, 2010

Convert ArgoUML to XMI

If you want to use ArchGenXML on UML models generated with ArgoUML >= 0.28, you'll have to export them to .xmi first. This is a quick way to do that automatically before running agx.

A shell script:
#!/bin/bash
# argouml2xmi.sh
# Creates a .xmi file from an ArgoUML-generated .uml file.
# Usage: ./argouml2xmi.sh filename.uml
# A file called filename.xmi will be created.

if [ ! -n "$1" ]
then
echo "Usage: `basename $0` input_file"
exit
fi

XMI_FILE=`echo $1 | sed 's/\.uml/\.xmi/'`
echo '<?xml version = "1.0" encoding = "UTF-8" ?>' > $XMI_FILE
sed -n '/<XMI*/,/<\/XMI>/p' $1 >> $XMI_FILE


Let the Makefile in your uml/ directory read:
default:
./argouml2xmi.sh MyProject.uml
archgenxml MyProject.xmi ../

and you'll only have to do is run make -C uml/

No comments: