PyEmofUC

XMI textual format for model serialization

J.M. Drake, P. López Martínez and C. Cuevas

Software Engineering and Real-Time (ISTR) - University of Cantabria

Table of Contents

XMI specification

The XMI specification has been proposed by the OMG in order to standardize the interchange of models among heterogeneous environments and for storage in persistent files.
An XMI document is an XML document formalized through the W3C-Schema
XMI.xsd.

In the PyEmofUC environment, the XMI format is used in two cases:
The XMI textual representation uses tagged XML text and incorporates certain restrictions and extensions to standardize its formulation within UML environments.
In addition, it
describes solutions for creating XML documents and Schemas that share objects consistently.

Key aspects specified by the XMI specification are:

Specific XMI specification in PyEmofUC

Structure: Although XMI imposes strong restrictions on the structure and format for model information codification, many options are left open for accommodating the formats used by different environment designers.
PyEmofUC adopts the following rules for textual encoding of models and meta-models:

Main element of a meta-model

<?xml version="1.0" encoding="UTF-8"?>

<emof:METAMODEL date="2015-03-06"

             uri="http://unican.es/istr/PyEmofUC/CountyCity/County"

             mmUrl="http://unican.es/istr/PyEmofUC/EmofUC.xmi"

             importedUrls="platform:CountyCity/City.xmi"

             nsPrefix="cnty"

             rootType="cnty.County"

             xmlns:xmi="http://www.omg.org/XMI"

             xmlns:emof="http://unican.es/istr/PyEmofUC/EmofUC"

             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

             xsi:schemaLocation="http://unican.es/istr/PyEmofUC/EmofUC ..\EMOF.xsd">

             <rootPackage name="rootPackage" . . . .

             . . . . .

             </rootPackage>

</emof:METAMODEL>

Main element of a model

<?xml version="1.0" encoding="UTF-8"?>

<cty:MODEL date="2013-03-07T20:34:18"

             uri="http://unican.es/istr/PyEmofUC/CountyCity/EagleCity"

             mmUrl="platform:CountyCity/City.xmi"

             importedUrls="platform:CountyCity/EagleCounty.xmi"

             nsPrefix="ecty"

             xmlns:xmi="http://www.omg.org/XMI"

             xmlns:cty="http://unican.es/istr/PyEmofUC/CountyCity/City"

             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

             xsi:schemaLocation="http://unican.es/istr/PyEmofUC/CountyCity/City City.xsd">

             <rootPackage . . . .

              . . . .

             </rootPackage>

</cty:MODEL>



<company xmi:id="ecty.AbbyBank" xsi:type="cty:Company" . . . >

                <employ . . .  />

                . . . .

</company>

References formulation: In the XMI formulation, references to model elements from elements of the same model or other models use the generic
URI syntax. However, in order to unify these reference with other XML standards like XLink, without duplicating data, different format schemes are used, depending from where it is done:

Schemas

Every XMI file defining models or meta-models within the PyEmofUC environment has an associated W3C-Schema generated from the corresponding meta-model.
It defines the structure, format and content of any model compliant to that meta-model.

The goal of the generated schema is to provide assistance to the operator when he uses a smart XML editor for creating or editing models compliant to it.
Its formulation is lax, using the following criteria:

  1. The names of the elements of the nested elements and attributes are defined for the corresponding element in the metamodel.
  2. Nested elements are unordered.
  3. Derived attributes are not included.
  4. The xml: id and xsi: type attributes are mandatory for every element.
  5. Every attribute is of xsd:string type.
  6. Every cross-reference is of xsd:anyURI type.
 
The table below shows a sample meta-model (left column) and its corresponding schema (right column), as generated by PyEmofUC.


<?xml version="1.0" encoding="UTF-8"?>

<emof:METAMODEL date="2015-03-06"

      uri="http://unican.es/istr/PyEmofUC/CountyCity/City"

      mmUrl="http://unican.es/istr/PyEmofUC/EmofUC.xmi"

      importedUrls="platform:CountyCity/County.xmi"

      nsPrefix="cty"

      rootType="#cty.CompanyDirectory"

      xmlns:xmi="http://www.omg.org/XMI"

      xmlns:emof="http://unican.es/istr/PyEmofUC/EmofUC"

      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

      xsi:schemaLocation="http://unican.es/.../EmofUC ..\EMOF.xsd">            

      <rootPackage name="rootPackage"

            xmi:id="cty.rootPacage"

            xsi:type="emof:Package">

             <ownedType name="CompanyDirectory"

                  xmi:id="cty.CompanyDirectory"

                  xsi:type="emof:Class"

                  superclass="emof#emof.Object">

                   <ownedAttribute name="company"

                        xmi:id="cty.CompanyDirectory.company"

                        xsi:type="emof:Property"

                        theType="#cty.Company"

                        isComposite="True"

                        upper="*"/>

             </ownedType>

             <ownedType name="Company"

                  xmi:id="cty.Company"

                  xsi:type="emof:Class"

                  superclass="emof#emof.Object">

                   <ownedAttribute name="name"

                        xmi:id="cty.Company.name"

                        xsi:type="emof:Property"

                        theType="emof#emof.PyString"/>

                   <ownedAttribute name="employ"

                        xmi:id="cty.Company.employ"

                        xsi:type="emof:Property"

                        theType="#cty.Employ"

                        isComposite="True"

                        lower='0'

                        upper="*"

                        opposite="#cty.Employ.employer"/>

             </ownedType>

            

             <ownedType name="Employ"

                  xmi:id="cty.Employ"

                  xsi:type="emof:Class"

                  superclass="emof#emof.Object">

                   <ownedAttribute name="name"

                        xmi:id="cty.Employ.name"

                        xsi:type="emof:Property"

                        theType="emof#emof.PyString"/>

                   <ownedAttribute name="salary"

                        xmi:id="cty.Employ.salary"

                        xsi:type="emof:Property"

                        theType="emof#emof.PyReal"

                        default="0.0"/>

                   <ownedAttribute name="employer"

                        xmi:id="cty.Employ.employer"

                        xsi:type="emof:Property"

                        theType="#cty.Company"

                        opposite="#cty.Company.employ"/>

                   <ownedAttribute name="worker"

                        xmi:id="cty.Employ.worker"

                        xsi:type="emof:Property"

                        theType="cnty#cnty.Adult"

                        opposite="cnty#cnty.Adult.job"/>

             </ownedType>

      </rootPackage>

</emof:METAMODEL>

<?xml version="1.0" encoding="UTF-8"?>

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"

      xmlns:cty="http://unican.es/istr/PyEmofUC/CountyCity/City"

      xmlns:xmi=http://www.omg.org/XMI

      xmlns:emof=http://unican.es/istr/PyEmofUC/EmofUC

      targetNamespace="http://unican.es/istr/PyEmofUC/CountyCity/City">

      <xsd:import namespace=http://www.omg.org/XMI

            schemaLocation="../XMI.xsd"/>

      <xsd:import namespace=http://unican.es/istr/PyEmofUC/EmofUC

            schemaLocation="../EMOF.xsd"/>

      <xsd:complexType name="CompanyDirectory">

             <xsd:complexContent>

                   <xsd:extension base="emof:PyEmofObject">

                         <xsd:sequence>

                                <xsd:element name="company"

                                     type="cty:Company"

                                    maxOccurs="unbounded"/>

                         </xsd:sequence>

                   </xsd:extension>

             </xsd:complexContent>

      </xsd:complexType>

      <xsd:complexType name="Company">

             <xsd:complexContent>

                   <xsd:extension base="emof:PyEmofObject">

                         <xsd:sequence>

                                <xsd:element name="employ"

                                    type="cty:Employ"

                                    minOccurs="0"

                                    maxOccurs="unbounded"/>

                         </xsd:sequence>

                         <xsd:attribute name="name"

                              type="xsd:string"

                              use="required"/>

                   </xsd:extension>

             </xsd:complexContent>

      </xsd:complexType>

      <xsd:complexType name="Employ">

             <xsd:complexContent>

                   <xsd:extension base="emof:PyEmofObject">

                         <xsd:attribute name="name"

                              type="xsd:string"

                              use="required"/>

                         <xsd:attribute name="salary"

                              type="xsd:float"        

                              use="optional"

                              default="0.0"/>

                         <xsd:attribute name="employer"

                              type="xsd:anyURI"

                              use="optional"/>

                         <xsd:attribute name="worker"

                              type="xsd:anyURI"

                              use="required"/>

                   </xsd:extension>

             </xsd:complexContent>

      </xsd:complexType>

      <!-- ROOT ELEMENT -->

      <xsd:element name="MODEL">

             <xsd:complexType>

                   <xsd:complexContent>

                         <xsd:extension base="emof:Model">

                                <xsd:sequence>

                                      <xsd:element name="rootPackage"

                                          type="cty:CompanyDirectory"

                                          maxOccurs="unbounded"/>

                                </xsd:sequence>

                         </xsd:extension>

                   </xsd:complexContent>

             </xsd:complexType>

      </xsd:element>

</xsd:schema>


Documents

Link of interest