SDMetrics home page
The Software Design Metrics tool for the UML
Sitemap

Parsing the XMI Extensions of Enterprise Architect

January 2, 2018, Jürgen Wüst. Category: Announcements,Tips & Tricks

SDMetrics 2.35 introduces a small extension to the XMI parser. Assume we need to access information such as the author or a documentation string from the XMI extension part of Enterprise Architect. This information is encoded as follows:

<uml:Model xmi:type="uml:Model" name="EA_Model" visibility="public">
 <packagedElement xmi:type="uml:Package" xmi:id="4A3564" name="test" visibility="public" />
</uml:Model>
<xmi:Extension extender="Enterprise Architect" extenderID="6.5">
  <elements>
    <element xmi:idref="4A3564" xmi:type="uml:Package" name="test" >
      <properties isSpecification="false" sType="Package" scope="public" 
          documentation="Something important about this package." />
      <project author="jw" version="1.0" created="2018-01-02 09:05:22" 
          modified="2018-01-02 09:07:34" complexity="1" status="Proposed"/>
      ...
    </element>
  </elements>
</xmi:Extension>

The XMI extension part contains an <element>-tag with an XMI idref attribute that identifies the extended element, and some sub-tags with attributes for documentation and author. This should be a simple task for SDMetrics: just add an “EA Extension element” to SDMetrics’ meta-model and write the appropriate XMI transformation, maybe like so:

<!-- new meta-model element -->
<modelelement name="eaextensionelement">
  <attribute name="eaextelemref" type="ref" />
  <attribute name="documentation" type="data" />
  <attribute name="author" type="data" />
</modelelement>

<!-- XMI transformation for the new meta-model element -->
<xmitransformation modelelement="eaextensionelement" xmipattern="element" 
    requirexmiid="false" condition="geometry=''">
  <trigger name="eaextelemref" type="attrval" attr="xmi:idref" />
  <trigger name="name" type="attrval" attr="name" />
  <trigger name="documentation" type="cattrval" attr="documentation" src="properties" />
  <trigger name="author" type="cattrval" attr="author" src="project" />
</xmitransformation>

Because the <element>-tag has no XMI ID, we need to set the requirexmiid attribute of the XMI transformation to false. We also add a condition geometry=” (the element must have no or an empty geometry attribute), because Enterprise Architect also uses <element>-tags to store diagram information and we don’t want to pick these up here.

However, when we add the above definitions to SDMetrics’ project files, nothing happens! The XMI parser does not recognise the new model element. This is because the following rule is hardcoded in the XMI parser: an XML tag in the input XMI file that has no XMI ID but does have an XMI idref attribute cannot trigger the creation of a new model element. The origin of this rule goes back to the days of XMI 1.0 and XMI 1.1, where element cross-references were serialized like this:

<UML:Generalization xmi.id = '889' isSpecification = 'false'>
  <UML:Generalization.child>
    <UML:Class xmi.idref = '888'/>
  </UML:Generalization.child>
  <UML:Generalization.parent>
    <UML:Class xmi.idref = '866'/>
  </UML:Generalization.parent>
</UML:Generalization>

Without the hardcoded “idref rule”, lines such as the ones shown in boldface would trigger the creation of new, empty elements, which would mess up the measurement results.

Now we know that the <element>-tag is not recognized because it contains an XMI idref attribute, and there is no other workaround for this problem. Obviously, this situation needs to be remedied. SDMetrics 2.35 therefore introduces a new attribute allowxmiidref for XMI transformations to bypass the “idref rule” if needed:

<xmitransformation modelelement="eaextensionelement" xmipattern="element" 
    requirexmiid="false" allowxmiidref="true" condition="geometry=''">
  ... remainder of the triggers as above.

When we add this new attribute to our definition, SDMetrics 2.35 picks up the <element>-tag as expected. We can now go ahead and define custom metrics that use information from the Enterprise Architect extension part:

<metric name="EAAuthor" domain="package">
  <description>Author of the package.</description>
  <filtervalue relation="eaextelemref" target="eaextensionelement" 
    value="author"/> 
</metric>

<metric name="EADocumentation" domain="package">
  <description>Documentation for the package.</description>
  <filtervalue relation="eaextelemref" target="eaextensionelement" 
    value="documentation"/> 
</metric>

This will add two more columns to the metric view for packages, showing the author and documentation string for each package.

Generating UML Reports From XMI Files

February 24, 2014, Jürgen Wüst. Category: Development

Occasionally I receive requests from people looking for a simple way to generate a report from an XMI file. For example, they may need to collect a list of all class attributes that satisfy a certain condition, and write them to some HTML or XML file. Depending on the task at hand, XSLT could work… [Continue reading]

Counting OCL Expressions in UML Classes

January 9, 2014, Jürgen Wüst. Category: Tips & Tricks

In this post we’ll look at another real-life case study of how to adapt SDMetrics in order to solve a particular measurement problem. An SDMetrics user needed to count the OCL expressions in classes. SDMetrics does not produce this count out of the box, but needs a little tweaking. In the UML2, an OCL expression… [Continue reading]

Overview of the Changes in SDMetrics V2.31

July 3, 2013, Jürgen Wüst. Category: Announcements

SDMetrics V2.31 was released today. This is a maintenance release that addresses some issues with the XMI import. Automatic recognition of XMI 2.4/2.4.1 files Ever since XMI 1.0, the XMI standards mandated a “version” attribute in the root element of the XMI file to indicate the XMI version of the file. It was simple and… [Continue reading]

Survey of UML Quality Modeling Papers: Less Than One Third Contain Empirical Work

May 28, 2013, Jürgen Wüst. Category: Measurement

I found an interesting review paper titled “A Systematic Literature Review on the Quality of UML Models” by Marcela Genero, Ana Fernández-Saez, H. James Nelson, Geert Poels, and Mario Piattini. It was published in the Journal of Database Management 22 (3), 46-70, 2011. You can also find it here. The paper aims to determine the… [Continue reading]

SDMetrics – Not For UML Models Only

April 8, 2013, Jürgen Wüst. Category: Tips & Tricks

SDMetrics advertizes itself as “The Software Design Metrics tool for the UML”. SDMetrics has a flexible XMI parser to import UML models, as XMI is the most common UML model interchange format. But XMI is not limited to UML model interchange. It can be used to serialize any MOF-based models to XML. Therefore, SDMetrics too… [Continue reading]

Customizing the XMI Import for Enterprise Architect UML Component Diagrams

February 20, 2013, Jürgen Wüst. Category: Tips & Tricks

Recently, some SDMetrics Open Core users approached me with a neat little measurement problem that is ideally suited for this blog. They used Enterprise Architect to create UML 1.3 component diagrams with classifier roles. The XMI output of Enterprise Architect for these diagrams contained several tagged values for the classifier role instances, including two with… [Continue reading]

The Effects of Stability on UML Model Composition Effort

January 23, 2013, Jürgen Wüst. Category: Measurement

The January 2013 issue of “Software & Systems Modeling” contains a new empirical study on UML quality modeling. The paper is titled “Effects of stability on model composition effort: an exploratory study ” by Kleinner Farias, Alessandro Garcia, and Carlos Lucena. The full paper is available for download. Here is my review. The paper investigates… [Continue reading]

More Quality Metrics for UML Sequence Diagrams

December 21, 2012, Jürgen Wüst. Category: Tips & Tricks

In a previous post, we have defined a basic set of size and complexity metrics for UML sequence diagrams with SDMetrics. Today, we’ll add a few more sequence diagram metrics that are potentially useful to identify design flaws. I will show how to implement these metrics using the SDMetricsML. 1. Number of “self” messages The… [Continue reading]

Ten Years of UML Design Quality Measurement

December 1, 2012, Jürgen Wüst. Category: Announcements

SDMetric v1.0 was released on December 1st 2002, 10 years ago on this very day. This calls for immediate celebration! And what better way is there to celebrate than with a bunch of software quality related statistics? So, here we go: SDMetrics Number of major releases: 8 Number of minor releases: 4 Size of first… [Continue reading]

Older Posts »