Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » JET2 access to ecore references
JET2 access to ecore references [message #4344] Tue, 13 March 2007 15:12 Go to next message
Vladimir Sosnin is currently offline Vladimir SosninFriend
Messages: 19
Registered: July 2009
Junior Member
Hello,

I have a Ecore model wich contains elements with references. But I can't
access referenced content when process instance of a model serialized
into XMI using JET2 template. I unsuccessfully tried to access it as
attribute. Even result of <c:dump> doesn't contain any attributes of
processed XMI file. Example model, model instance and dump.xml are below.

Regards,
Vladimir

Example model:
<?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="simple"
nsURI="http://simple" nsPrefix="smpl">
<eClassifiers xsi:type="ecore:EClass" name="SomeClass">
<eStructuralFeatures xsi:type="ecore:EReference" name="reference"
upperBound="-1"
eType="#//SomeVar"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="SomeVar">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
lowerBound="1" eType="ecore:EDataType
http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Container">
<eStructuralFeatures xsi:type="ecore:EReference" name="vars"
upperBound="-1" eType="#//SomeVar"
containment="true"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="class"
eType="#//SomeClass"
containment="true"/>
</eClassifiers>
</ecore:EPackage>

Example model instance:
<?xml version="1.0" encoding="ASCII"?>
<smpl:Container xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:smpl="http://simple" xsi:schemaLocation="http://simple My.ecore">
<vars name="test1"/>
<vars name="test2"/>
<class reference="//@vars.0 //@vars.1"/>
</smpl:Container>


Resulting dump file:
<?xml version="1.0" encoding="utf-8"?>
<contents>
<smpl:vars name="test1"/>
<smpl:vars name="test2"/>
<smpl:class/>
</contents>
Re: JET2 access to ecore references [message #5240 is a reply to message #4344] Wed, 21 March 2007 13:47 Go to previous messageGo to next message
Paul Elder is currently offline Paul ElderFriend
Messages: 849
Registered: July 2009
Senior Member
Vladimir

The c:dump tag attempts to give an 'XML-view' of the document the engine is
processing - it does not perfectly represent an EMF document.

Nevertheless, the following XPath expression should successfully navigate
your 'reference' feature:

/contents/class/reference

And, a more complete example:

<c:log>
A quick navigation of your model
<c:iterate select="/contents" var="container">
Vars:
<c:iterate select="$container/vars" var="vars">
name = <c:get select="$vars/@name"/>
</c:iterate>
Classes:
<c:iterate select="$container/class" var="class">
class
<c:iterate select="$class/reference" var="reference">
reference to var named = <c:get select="$reference/@name"/>
</c:iterate>
</c:iterate>
</c:iterate>
<c:/log>

"Vladimir Sosnin" <antiso@gmail.com> wrote in message
news:et6f1l$j3n$1@utils.eclipse.org...
> Hello,
>
> I have a Ecore model wich contains elements with references. But I can't
> access referenced content when process instance of a model serialized into
> XMI using JET2 template. I unsuccessfully tried to access it as attribute.
> Even result of <c:dump> doesn't contain any attributes of processed XMI
> file. Example model, model instance and dump.xml are below.
>
> Regards,
> Vladimir
>
> Example model:
> <?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="simple"
> nsURI="http://simple" nsPrefix="smpl">
> <eClassifiers xsi:type="ecore:EClass" name="SomeClass">
> <eStructuralFeatures xsi:type="ecore:EReference" name="reference"
> upperBound="-1"
> eType="#//SomeVar"/>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EClass" name="SomeVar">
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
> lowerBound="1" eType="ecore:EDataType
> http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EClass" name="Container">
> <eStructuralFeatures xsi:type="ecore:EReference" name="vars"
> upperBound="-1" eType="#//SomeVar"
> containment="true"/>
> <eStructuralFeatures xsi:type="ecore:EReference" name="class"
> eType="#//SomeClass"
> containment="true"/>
> </eClassifiers>
> </ecore:EPackage>
>
> Example model instance:
> <?xml version="1.0" encoding="ASCII"?>
> <smpl:Container xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:smpl="http://simple" xsi:schemaLocation="http://simple My.ecore">
> <vars name="test1"/>
> <vars name="test2"/>
> <class reference="//@vars.0 //@vars.1"/>
> </smpl:Container>
>
>
> Resulting dump file:
> <?xml version="1.0" encoding="utf-8"?>
> <contents>
> <smpl:vars name="test1"/>
> <smpl:vars name="test2"/>
> <smpl:class/>
> </contents>
Re: JET2 access to ecore references [message #6424 is a reply to message #5240] Wed, 21 March 2007 18:03 Go to previous messageGo to next message
Vladimir Sosnin is currently offline Vladimir SosninFriend
Messages: 19
Registered: July 2009
Junior Member
Paul,

You are completely right. I haven't tried to access to references as to
descendants, just as to attributes. Seems like I was confused by
structure of XMI file.

Thank you very much!
Vladimir

Paul Elder wrote:
> Vladimir
>
> The c:dump tag attempts to give an 'XML-view' of the document the engine is
> processing - it does not perfectly represent an EMF document.
>
> Nevertheless, the following XPath expression should successfully navigate
> your 'reference' feature:
>
> /contents/class/reference
>
> And, a more complete example:
>
> <c:log>
> A quick navigation of your model
> <c:iterate select="/contents" var="container">
> Vars:
> <c:iterate select="$container/vars" var="vars">
> name = <c:get select="$vars/@name"/>
> </c:iterate>
> Classes:
> <c:iterate select="$container/class" var="class">
> class
> <c:iterate select="$class/reference" var="reference">
> reference to var named = <c:get select="$reference/@name"/>
> </c:iterate>
> </c:iterate>
> </c:iterate>
> <c:/log>
>
> "Vladimir Sosnin" <antiso@gmail.com> wrote in message
> news:et6f1l$j3n$1@utils.eclipse.org...
>> Hello,
>>
>> I have a Ecore model wich contains elements with references. But I can't
>> access referenced content when process instance of a model serialized into
>> XMI using JET2 template. I unsuccessfully tried to access it as attribute.
>> Even result of <c:dump> doesn't contain any attributes of processed XMI
>> file. Example model, model instance and dump.xml are below.
>>
>> Regards,
>> Vladimir
>>
>> Example model:
>> <?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="simple"
>> nsURI="http://simple" nsPrefix="smpl">
>> <eClassifiers xsi:type="ecore:EClass" name="SomeClass">
>> <eStructuralFeatures xsi:type="ecore:EReference" name="reference"
>> upperBound="-1"
>> eType="#//SomeVar"/>
>> </eClassifiers>
>> <eClassifiers xsi:type="ecore:EClass" name="SomeVar">
>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
>> lowerBound="1" eType="ecore:EDataType
>> http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>> </eClassifiers>
>> <eClassifiers xsi:type="ecore:EClass" name="Container">
>> <eStructuralFeatures xsi:type="ecore:EReference" name="vars"
>> upperBound="-1" eType="#//SomeVar"
>> containment="true"/>
>> <eStructuralFeatures xsi:type="ecore:EReference" name="class"
>> eType="#//SomeClass"
>> containment="true"/>
>> </eClassifiers>
>> </ecore:EPackage>
>>
>> Example model instance:
>> <?xml version="1.0" encoding="ASCII"?>
>> <smpl:Container xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>> xmlns:smpl="http://simple" xsi:schemaLocation="http://simple My.ecore">
>> <vars name="test1"/>
>> <vars name="test2"/>
>> <class reference="//@vars.0 //@vars.1"/>
>> </smpl:Container>
>>
>>
>> Resulting dump file:
>> <?xml version="1.0" encoding="utf-8"?>
>> <contents>
>> <smpl:vars name="test1"/>
>> <smpl:vars name="test2"/>
>> <smpl:class/>
>> </contents>
>
>
Re: JET2 access to ecore references [message #19368 is a reply to message #6424] Sun, 03 June 2007 22:20 Go to previous messageGo to next message
Joaquin  Cañadas is currently offline Joaquin CañadasFriend
Messages: 25
Registered: July 2009
Junior Member
Dear Paul,
I have the same problem but my reference is not multiple, so I can not
iterate over the $class/reference to obtain the @name attribute value.
However, I used

<c:get select="$class/@reference/@name"/>

and it does not work.
Maybe I have not configured correctly the Jet project to use a XMI model
based on EMF. Some ideas?

Thank you



Vladimir Sosnin escribió:
> Paul,
>
> You are completely right. I haven't tried to access to references as to
> descendants, just as to attributes. Seems like I was confused by
> structure of XMI file.
>
> Thank you very much!
> Vladimir
>
> Paul Elder wrote:
>> Vladimir
>>
>> The c:dump tag attempts to give an 'XML-view' of the document the
>> engine is processing - it does not perfectly represent an EMF document.
>>
>> Nevertheless, the following XPath expression should successfully
>> navigate your 'reference' feature:
>>
>> /contents/class/reference
>>
>> And, a more complete example:
>>
>> <c:log>
>> A quick navigation of your model
>> <c:iterate select="/contents" var="container">
>> Vars:
>> <c:iterate select="$container/vars" var="vars">
>> name = <c:get select="$vars/@name"/>
>> </c:iterate>
>> Classes:
>> <c:iterate select="$container/class" var="class">
>> class
>> <c:iterate select="$class/reference" var="reference">
>> reference to var named = <c:get select="$reference/@name"/>
>> </c:iterate>
>> </c:iterate>
>> </c:iterate>
>> <c:/log>
>>
>> "Vladimir Sosnin" <antiso@gmail.com> wrote in message
>> news:et6f1l$j3n$1@utils.eclipse.org...
>>> Hello,
>>>
>>> I have a Ecore model wich contains elements with references. But I
>>> can't access referenced content when process instance of a model
>>> serialized into XMI using JET2 template. I unsuccessfully tried to
>>> access it as attribute. Even result of <c:dump> doesn't contain any
>>> attributes of processed XMI file. Example model, model instance and
>>> dump.xml are below.
>>>
>>> Regards,
>>> Vladimir
>>>
>>> Example model:
>>> <?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="simple"
>>> nsURI="http://simple" nsPrefix="smpl">
>>> <eClassifiers xsi:type="ecore:EClass" name="SomeClass">
>>> <eStructuralFeatures xsi:type="ecore:EReference" name="reference"
>>> upperBound="-1"
>>> eType="#//SomeVar"/>
>>> </eClassifiers>
>>> <eClassifiers xsi:type="ecore:EClass" name="SomeVar">
>>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
>>> lowerBound="1" eType="ecore:EDataType
>>> http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>>> </eClassifiers>
>>> <eClassifiers xsi:type="ecore:EClass" name="Container">
>>> <eStructuralFeatures xsi:type="ecore:EReference" name="vars"
>>> upperBound="-1" eType="#//SomeVar"
>>> containment="true"/>
>>> <eStructuralFeatures xsi:type="ecore:EReference" name="class"
>>> eType="#//SomeClass"
>>> containment="true"/>
>>> </eClassifiers>
>>> </ecore:EPackage>
>>>
>>> Example model instance:
>>> <?xml version="1.0" encoding="ASCII"?>
>>> <smpl:Container xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>> xmlns:smpl="http://simple" xsi:schemaLocation="http://simple My.ecore">
>>> <vars name="test1"/>
>>> <vars name="test2"/>
>>> <class reference="//@vars.0 //@vars.1"/>
>>> </smpl:Container>
>>>
>>>
>>> Resulting dump file:
>>> <?xml version="1.0" encoding="utf-8"?>
>>> <contents>
>>> <smpl:vars name="test1"/>
>>> <smpl:vars name="test2"/>
>>> <smpl:class/>
>>> </contents>
>>
>>
Re: JET2 access to ecore references [message #19460 is a reply to message #6424] Mon, 04 June 2007 12:36 Go to previous messageGo to next message
Joaquin  Cañadas is currently offline Joaquin CañadasFriend
Messages: 25
Registered: July 2009
Junior Member
Dear Paul / Vladimir,
Your example seems very easy to test, so I tried it. First, I created a
new EMFT Jet Transformation Project, copying in "sample.xml" the
instance model that appears below, and in "dump.jet" the jet code as you
wrote. After that I created a "simple.ecore" file with the example model
as appears later (without the <c:log> tags) and set the plugin.xml
modelschema field as "simple.ecore". Then, I executed the Jet project,
but the result was:

A quick navigation of your model
Vars:
name = test1
name = test2
Classes:
class

So references are not correctly managed!!!!

Is there some missing??? Is there any configuration step necessary to
say that the instance model is an EMF based XMI model?

Thank you in advance.
Joaquin


Vladimir Sosnin escribió:
> Paul,
>
> You are completely right. I haven't tried to access to references as to
> descendants, just as to attributes. Seems like I was confused by
> structure of XMI file.
>
> Thank you very much!
> Vladimir
>
> Paul Elder wrote:
>> Vladimir
>>
>> The c:dump tag attempts to give an 'XML-view' of the document the
>> engine is processing - it does not perfectly represent an EMF document.
>>
>> Nevertheless, the following XPath expression should successfully
>> navigate your 'reference' feature:
>>
>> /contents/class/reference
>>
>> And, a more complete example:
>>
>> <c:log>
>> A quick navigation of your model
>> <c:iterate select="/contents" var="container">
>> Vars:
>> <c:iterate select="$container/vars" var="vars">
>> name = <c:get select="$vars/@name"/>
>> </c:iterate>
>> Classes:
>> <c:iterate select="$container/class" var="class">
>> class
>> <c:iterate select="$class/reference" var="reference">
>> reference to var named = <c:get select="$reference/@name"/>
>> </c:iterate>
>> </c:iterate>
>> </c:iterate>
>> <c:/log>
>>
>> "Vladimir Sosnin" <antiso@gmail.com> wrote in message
>> news:et6f1l$j3n$1@utils.eclipse.org...
>>> Hello,
>>>
>>> I have a Ecore model wich contains elements with references. But I
>>> can't access referenced content when process instance of a model
>>> serialized into XMI using JET2 template. I unsuccessfully tried to
>>> access it as attribute. Even result of <c:dump> doesn't contain any
>>> attributes of processed XMI file. Example model, model instance and
>>> dump.xml are below.
>>>
>>> Regards,
>>> Vladimir
>>>
>>> Example model:
>>> <?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="simple"
>>> nsURI="http://simple" nsPrefix="smpl">
>>> <eClassifiers xsi:type="ecore:EClass" name="SomeClass">
>>> <eStructuralFeatures xsi:type="ecore:EReference" name="reference"
>>> upperBound="-1"
>>> eType="#//SomeVar"/>
>>> </eClassifiers>
>>> <eClassifiers xsi:type="ecore:EClass" name="SomeVar">
>>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
>>> lowerBound="1" eType="ecore:EDataType
>>> http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>>> </eClassifiers>
>>> <eClassifiers xsi:type="ecore:EClass" name="Container">
>>> <eStructuralFeatures xsi:type="ecore:EReference" name="vars"
>>> upperBound="-1" eType="#//SomeVar"
>>> containment="true"/>
>>> <eStructuralFeatures xsi:type="ecore:EReference" name="class"
>>> eType="#//SomeClass"
>>> containment="true"/>
>>> </eClassifiers>
>>> </ecore:EPackage>
>>>
>>> Example model instance:
>>> <?xml version="1.0" encoding="ASCII"?>
>>> <smpl:Container xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>> xmlns:smpl="http://simple" xsi:schemaLocation="http://simple My.ecore">
>>> <vars name="test1"/>
>>> <vars name="test2"/>
>>> <class reference="//@vars.0 //@vars.1"/>
>>> </smpl:Container>
>>>
>>>
>>> Resulting dump file:
>>> <?xml version="1.0" encoding="utf-8"?>
>>> <contents>
>>> <smpl:vars name="test1"/>
>>> <smpl:vars name="test2"/>
>>> <smpl:class/>
>>> </contents>
>>
>>
Re: JET2 access to ecore references [message #19642 is a reply to message #19368] Mon, 04 June 2007 14:21 Go to previous messageGo to next message
Paul Elder is currently offline Paul ElderFriend
Messages: 849
Registered: July 2009
Senior Member
Hi:

$class/@reference/@name doesn't make much sense as an XPath expression, as
attributes don't have attributes. JET is loading the XMI file into EMF
EObjects, and what was an XML attribute 'reference' becomes an EMF
EReference, which JET interprets as an element. The expression

$class/reference/@name

should work better.

Quick literally, JET is unaware the the model is represented in XMI on disk.
All it has access to is the in memory representation that EMF defined. So
from the point of view of faithfully representing the XMI content, JET (and
EMF for that matter) are not succeeding. But, by using EMF, you get
capabilities (such as non-containment references) that are difficult to
accomplish in XML along.

Paul

"eclipse" <jjcanada@ual.es> wrote in message
news:f3ver7$bi8$1@build.eclipse.org...
> Dear Paul,
> I have the same problem but my reference is not multiple, so I can not
> iterate over the $class/reference to obtain the @name attribute value.
> However, I used
>
> <c:get select="$class/@reference/@name"/>
>
> and it does not work.
> Maybe I have not configured correctly the Jet project to use a XMI model
> based on EMF. Some ideas?
>
> Thank you
>
>
>
> Vladimir Sosnin escribi
Re: JET2 access to ecore references [message #19686 is a reply to message #19460] Mon, 04 June 2007 14:22 Go to previous message
Paul Elder is currently offline Paul ElderFriend
Messages: 849
Registered: July 2009
Senior Member
I think I've responded to this on another thread
news:f4165v$30p$1@build.eclipse.org...


"Joaqu
Previous Topic:Templates not in project?
Next Topic:JET2 access to ecore references... again
Goto Forum:
  


Current Time: Thu Apr 25 07:33:12 GMT 2024

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

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

Back to the top