The source code and an executable version of the script are available in gitHub: aixm/UML-to-XSD-scripts
Use the EA export script to generate the extension XML Schema in which the script triggers the generation of an extension element by recognizing the <<extension>> stereotype. Generation of the extension follows the AIXM generation rules.
Operating system and configuration
The script (start.bat) provided is configured for Windows systems and it includes a Java runtime engine. For other Windows versions, make sure that the Sparx Systems\EA\Java API is included in the windows Path, as shown below:
If EA is running from an application virtualization (or streaming) server (e.g. Microsoft App-V), the script might return an "ExceptionInInitializerError" error message. In this case please install EA directly on the local machine, because the script requires its Java API DLL to be registered and accessible.
A 32bits JRE (Java Runtime Environment) is included in the script files in order to guarantee the compatibility with both the code and the EA installation (that is currently always 32bits). If one day Sparx decides to publish a 64bits version of EA, the 64bits counterpart of the same version of the JRE should be used.
Executing the Script
There are some specific options that need to be set when executing the EA script, but most of the options will be defaulted. The schema generation scripts are used for both AIXM Core and Application Schemas.
Execute the 'start.bat' file of the 'step1 – EA export script'. This will open the following dialog window.
To load the UML model, i.e. the .eap file, click on the '...' button and drill down to the file location where you have the eap file.
Next, click on the 'AIRM' button. Then, click on the 'Load UML model' button.
When finished, the Console will show 'Loading complete…'.
Next, select the checkbox that you want to generate from the list of available Physical Models.
On the next screen, you can select/unselect the checkbox to 'Include documentation'. If you select the checkbox, it will generate out the annotation(s) in the XSD file from the UML diagrams' Notes section(s).
Check '[AIXM 5.1 Extension] XML SCHEMAS GENERATION - Generate Extension Features Schema' then press the 'Apply' button and select the package to be processed.
Additional step - order of associations
Note that an additional step might be required: re-order the XML extension properties (child elements) that correspond to associations in the UML model so that they appear in the same sequence as in the previous version of the extension(if applicable). The problem is that the EA export script has no control on the order in which these properties are generated in the XSD extension schema.
Therefore, they need to be re-ordered looking at the previous version of the extension XSD.This can be done with XSLT scripts provided for the core model. The scripts include the name of the AIXM 5.1 XSD reference file (see "AIXM_Features-5.1.xsd" on lines 78 and 79). In order to run the script on an extension schema, the reference schema file name needs to be replaced with the name of the extension reference schema (such as "MyPreviousExtension_Features_reference.xsd", for example).
The script takes as input the newly generated "features" extension XSD and the previous "reference" version. For those properties that have an identical name, the script re-arranges them in the same sequence that they were arranged in the previous XSD. Any new properties are listed at the end. Any missing properties are ignored.
Note: the script might not work correctly if the reference XSD uses the "xsd:" prefix for schema elements, such as xsd:sequence or xsd:choice. To solve this problem, the "xsd:" prefix needs to be removed from all the elements in the reference schema (with a simple text editor, using replace all).