Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » Problem trying to assign types to elements in the target model
Problem trying to assign types to elements in the target model [message #1764458] Tue, 30 May 2017 07:25 Go to next message
Bea Perez is currently offline Bea PerezFriend
Messages: 24
Registered: July 2012
Junior Member

I am trying to perform a transformation from a model conforming with the UML metamodel to another model conforming with another metamodel called PROV. This PROV metamodel is a ecore metamodel generated from a XML Schema by means of the EMF plugin. Such a metamodel is well parsed. The point is that the generated PROV metamodel has some elements which reference to types of EMF and XML, and I do not know how to create such types in the target model. More specifically, I need to create target elements EReferences and EAttributes which have an attribute EType:
- of type "EFeatureMap [org.eclipse.emf.ecore.util.FeatureMap]", in the case of EReferences.
- of type "QName [javax.xml.namespace.QName] ", in the case of EAttributes.

I do not know how to create such ETypes for each case. ┬┐any idea? all help is wellcome.


[Updated on: Tue, 30 May 2017 07:27]

Report message to a moderator

Re: Problem trying to assign types to elements in the target model [message #1767637 is a reply to message #1764458] Fri, 07 July 2017 20:22 Go to previous message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 379
Registered: September 2012
Location: Belgium
Senior Member

You cannot create those types directly in ATL. I'm also not sure you need to set those properties directly, because they may be derived from other properties in the same EClass. Example:

The following XSD element type specifies that a number of child elements can occur in any order, but the order is always preserved:
      <xsd:element name="regimen" minOccurs="0">
          <xsd:documentation>ordered day regimen of administration applicable either on a precised day or on basis of the frequency </xsd:documentation>
          <xsd:sequence maxOccurs="unbounded">
            <xsd:choice minOccurs="0">
              <xsd:element name="daynumber" type="xsd:positiveInteger">
                  <xsd:documentation>to be used to precise the day of the week of applicability in case of dosage regimen changing over time</xsd:documentation>
              <xsd:element name="date" type="DT:date">
                  <xsd:documentation>to be used to precise the date of applicability</xsd:documentation>

              <xsd:element name="weekday">
                  <xsd:documentation>to be used to precise the day of the week of applicability</xsd:documentation>
                    <xsd:extension base="weekdayType">
                        <xsd:element name="weeknumber" type="xsd:positiveInteger" minOccurs="0" />

            <xsd:element name="daytime" minOccurs="0">
                <xsd:documentation>proposed time of administration</xsd:documentation>
                  <xsd:element name="time" type="DT:time">
                      <xsd:documentation>proposed hour-min of administration</xsd:documentation>
                  <xsd:element name="dayperiod" type="dayperiodType">
                      <xsd:documentation>e.g. before noon</xsd:documentation>
            <xsd:element name="quantity" type="administrationquantityType">
                <xsd:documentation>number of pharmaceutical product units per intake / per administration (piece, puff, ml,...)</xsd:documentation>

This is translated to Ecore as follows:

The "group" EAttribute has this strange List of EFeatureMapEntry type, which cannot be used directly in ATL. It only serves to return the XML child elements in their original order, however, which is something that Ecore does not support (child elements are always grouped per property, never stored "loose" under the parent).

In order to create an XML document that leverages this specific XML-only ordering, ATL must add the child elements in the order they should be written, which requires imperative code:

lazy rule CodedPosologyDayNumberRegimen {
		s : EMRS!CodedPosology (
		t : KMEHR!RegimenType
	do {
		-- [DMW] Daytimes and quantities must be added in a pairwise way:
		for (e in s.entries) {
			for (m in e.momentsOfIntakeWithDosage) {

There are frequently other XML-specific datatypes inserted in your Ecore meta model, such as BigInteger and XMLGregorianCalendar. You'll probably need EMFTVM and its ability to access any Java method to work with these datatypes, for example:

--- Returns the current date/time.
helper def : currentDateTime : "#native"!"java::util::Date" =

--- Returns the current date (yyyy-MM-dd).
helper def : currentDate : "#native"!"javax::xml::datatype::XMLGregorianCalendar" =
	let date : String = thisModule.currentDateTime.toString('yyyy-MM-dd') in
    "#native"!"javax::xml::datatype::DatatypeFactory".refInvokeStaticOperation('newInstance', Sequence{}).newXMLGregorianCalendar(date);	

Previous Topic:Tutorials for working with UML Stereotypes and Composite Structure Diagrams
Next Topic:Obtaining ATL program from ATL model
Goto Forum:

Current Time: Fri Nov 16 19:48:13 GMT 2018

Powered by FUDForum. Page generated in 0.02233 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top