Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Instance of ECore Model(Use Of XMI for creating instance of ECore Model, Need of xmi:id atttribute)
Instance of ECore Model [message #656737] Mon, 28 February 2011 11:20 Go to next message
Dharam  is currently offline Dharam Friend
Messages: 18
Registered: December 2010
Junior Member
Hello,

(Sample Example)
My ECore model's textual format looks like this,

<?xml version="1.0" encoding="UTF-8"?>
<ecore:EPackage xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="mymodel"
nsURI="http://mymodel/1.0" nsPrefix="mymodel">
<eClassifiers xsi:type="ecore:EClass" name="Order">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="id" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="customer" lowerBound="1"
eType="#//Customer" containment="true"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="articles" upperBound="-1"
eType="#//Article" containment="true"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Customer">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="address" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Article">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="description" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="price" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EFloat"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="OrderSystem">
<eStructuralFeatures xsi:type="ecore:EReference" name="customers" upperBound="-1"
eType="#//Customer" containment="true"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="orders" upperBound="-1"
eType="#//Order" containment="true"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="articles" upperBound="-1"
eType="#//Article" containment="true"/>
</eClassifiers>
</ecore:EPackage>

Now I want to create an XMI instance of above MyModel.ecore.
But it asks me only for particular object only as an example OrederSystem.

In fact I want to create something like this,

XML ECORE prolog....
<OrderSystem xmi:id="123"..../>
<Customer xmi:id="123" />
<Article xmi:id="123"/>

So that later in this XMI file I can refer customer with id 123...

Is it posssible? If yes then what should be XML Prolog? As I am somewhat new to this, improve me if I am wrong anywhere..

[Updated on: Mon, 28 February 2011 11:50]

Report message to a moderator

Re: Instance of ECore Model [message #656795 is a reply to message #656737] Mon, 28 February 2011 15:55 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 30541
Registered: July 2009
Senior Member
Dharam,

Comments below.

Dharam wrote:
> Hello,
>
> (Sample Example)
> My ECore model's textual format looks like this,
>
> <?xml version="1.0" encoding="UTF-8"?>
> <ecore:EPackage xmi:version="2.0"
> xmlns:xmi="http://www.omg.org/XMI"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="mymodel"
> nsURI="http://mymodel/1.0" nsPrefix="mymodel">
> <eClassifiers xsi:type="ecore:EClass" name="Order">
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="id"
> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> <eStructuralFeatures xsi:type="ecore:EReference" name="customer"
> lowerBound="1"
> eType="#//Customer" containment="true"/>
> <eStructuralFeatures xsi:type="ecore:EReference" name="articles"
> upperBound="-1"
> eType="#//Article" containment="true"/>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EClass" name="Customer">
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="address"
> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EClass" name="Article">
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="description"
> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="price"
> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EFloat"/>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EClass" name="OrderSystem">
> <eStructuralFeatures xsi:type="ecore:EReference" name="customers"
> upperBound="-1"
> eType="#//Customer" containment="true"/>
> <eStructuralFeatures xsi:type="ecore:EReference" name="orders"
> upperBound="-1"
> eType="#//Order" containment="true"/>
> <eStructuralFeatures xsi:type="ecore:EReference" name="articles"
> upperBound="-1"
> eType="#//Article" containment="true"/>
> </eClassifiers>
> </ecore:EPackage>
>
> Now I want to create an XMI instance of above MyModel.ecore.
> But it asks me only for particular object only as an example
> OrederSystem.
> In fact I want to create something like this,
>
> XML ECORE prolog....
> <OrderSystem xmi:id="123"..../>
OrderSystems contain customers, so I'm not sure why you're expecting to
keep them at the root of the XML. You can create them as children of
OrderSystem from the context menu for the initial OrderSystem you create.
> <Customer xmi:id="123" />
> <Article cmi:id="123"/>
>
> So that later in this XMI file I can refer customer with id 123...
>
> Is it posssible? If yes then what should be XML Prolog? As I am
> somewhat new to this, improve me if I am wrong anywhere..
Previous Topic:[Teneo] Storing references to Ecore Model Elements - External annotation
Next Topic:Analyzing accessible EMF metamodels for project
Goto Forum:
  


Current Time: Tue Oct 15 03:32:42 GMT 2019

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

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

Back to the top