# astah* API User Guide

## [Import/Export XMI]

XMI Input/Output is supported in astah* professional.

#### [Export/Import XMI, Save as Project]

#### Export XMI

Export astah* Project file to XMI file (.xml).

Example of Export XMI

    import com.change_vision.jude.api.inf.project.ProjectAccessor;
    import com.change_vision.jude.api.inf.project.ProjectAccessorFactory;

    public class Test {
      public static void main(String[] args) {
        try {
            ProjectAccessor prjAccessor = ProjectAccessorFactory.getProjectAccessor();

            prjAccessor.open("C:\\API\\pro305.asta");
            prjAccessor.exportXMI("C:\\API\\pro305_xmi.xml");
            prjAccessor.close();

        } catch (Exception e) {
            e.printStackTrace();
        }
      }
    }

#### Import XMI

Import XMI project file(.xml) to a astah* project file.
Ensure to let the ClassPath go through the jar that locates in the astah* professional Install folder\lib to execute XMI Import.

#### Save as Project

Save as a new project(.asta).

Example of XMI Import and saving it as Project with name

    import com.change_vision.jude.api.inf.project.ProjectAccessor;
    import com.change_vision.jude.api.inf.project.ProjectAccessorFactory;

    public class Test {
      public static void main(String[] args) {
        try {
            ProjectAccessor prjAccessor = ProjectAccessorFactory.getProjectAccessor();

            prjAccessor.importXMI("C:\\API\\pro305_xmi.xml");
            prjAccessor.saveAs("C:\\API\\pro305_2.asta");
            prjAccessor.close();

        } catch (Exception e) {
            e.printStackTrace();
        }
      }
    }

#### Process of Import/Export XMI with astah* API

Here is a process of Import/Export XMI using astah* API.

Example: Export astah* project file to XMI - Modify the XMI - Import XMI - Save as astah* project file

    import com.change_vision.jude.api.inf.project.ProjectAccessor;
    import com.change_vision.jude.api.inf.project.ProjectAccessorFactory;

    public class Test {
      public static void main(String[] args) {
        try {
            ProjectAccessor prjAccessor = ProjectAccessorFactory.getProjectAccessor();

            prjAccessor.open("C:\\API\\pro305.asta");
            prjAccessor.exportXMI("C:\\API\\pro305_xmi.xml");
            prjAccessor.close();

            // Edit

            prjAccessor.importXMI("C:\\API\\pro305_xmi.xml");
            prjAccessor.saveAs("C:\\API\\pro305_2.asta");
            prjAccessor.close();

        } catch (Exception e) {
            e.printStackTrace();
        }
      }
    }

Home