Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » EObject to XML
EObject to XML [message #499580] Mon, 23 November 2009 11:57 Go to next message
Eclipse UserFriend
Originally posted by: luca_picello.mentor.com

Hallo folks,
I am wondering if and how I can extract the Xpath of an EObject which
refers to the nodes in the XML file.
But not specific to the emf-model, which is returned by
eObj.eResource().getURIFragment(eObj);

"//@uiTemplate/@classes/@furnitureClasses/@textClasses.0" (returned by
getURIFragment)
but
"//@uiTemplate/@classes/@furniture/@text[class='furnText2']"

where the XML file is:
<uiTemplate
<classes
<furniture
<text class="furnText2" ...
...

thanks in advance

Luca
Re: EObject to XML [message #499616 is a reply to message #499580] Mon, 23 November 2009 14:33 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30653
Registered: July 2009
Senior Member
Luca Picello wrote:
> Hallo folks,
> I am wondering if and how I can extract the Xpath of an EObject which
> refers to the nodes in the XML file.
> But not specific to the emf-model, which is returned by
> eObj.eResource().getURIFragment(eObj);
>
> "//@uiTemplate/@classes/@furnitureClasses/@textClasses.0" (returned
> by getURIFragment)
> but
> "//@uiTemplate/@classes/@furniture/@text[class='furnText2']"
In your Ecore model, on the "Funiture's" text containment EReference,
define the "class" EAttribute to be in the eKeys for that EReference.
>
> where the XML file is:
> <uiTemplate
> <classes
> <furniture
> <text class="furnText2" ...
> ...
>
> thanks in advance
>
> Luca
>
Re: EObject to XML [message #499909 is a reply to message #499616] Tue, 24 November 2009 14:02 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: luca_picello.mentor.com

Thanks Ed,
adding ecore:keys="class" it works fine. Thank you.
Another question: is it possible to retrieve the XML-Xpath instead of the
EMF-Xpath ?

Thank you in advance
Luca



"Ed Merks" <Ed.Merks@gmail.com> wrote in message
news:hee6fs$uf9$3@build.eclipse.org...
>
>
> Luca Picello wrote:
>> Hallo folks,
>> I am wondering if and how I can extract the Xpath of an EObject which
>> refers to the nodes in the XML file.
>> But not specific to the emf-model, which is returned by
>> eObj.eResource().getURIFragment(eObj);
>>
>> "//@uiTemplate/@classes/@furnitureClasses/@textClasses.0" (returned by
>> getURIFragment)
>> but
>> "//@uiTemplate/@classes/@furniture/@text[class='furnText2']"
> In your Ecore model, on the "Funiture's" text containment EReference,
> define the "class" EAttribute to be in the eKeys for that EReference.
>>
>> where the XML file is:
>> <uiTemplate
>> <classes
>> <furniture
>> <text class="furnText2" ...
>> ...
>>
>> thanks in advance
>>
>> Luca
>>
Re: EObject to XML [message #499912 is a reply to message #499909] Tue, 24 November 2009 14:10 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30653
Registered: July 2009
Senior Member
Luca,

No, there's only direct support for producing URI fragments.


Luca Picello wrote:
> Thanks Ed,
> adding ecore:keys="class" it works fine. Thank you.
> Another question: is it possible to retrieve the XML-Xpath instead of
> the EMF-Xpath ?
>
> Thank you in advance
> Luca
>
>
>
> "Ed Merks" <Ed.Merks@gmail.com> wrote in message
> news:hee6fs$uf9$3@build.eclipse.org...
>>
>>
>> Luca Picello wrote:
>>> Hallo folks,
>>> I am wondering if and how I can extract the Xpath of an EObject
>>> which refers to the nodes in the XML file.
>>> But not specific to the emf-model, which is returned by
>>> eObj.eResource().getURIFragment(eObj);
>>>
>>> "//@uiTemplate/@classes/@furnitureClasses/@textClasses.0" (returned
>>> by getURIFragment)
>>> but
>>> "//@uiTemplate/@classes/@furniture/@text[class='furnText2']"
>> In your Ecore model, on the "Funiture's" text containment EReference,
>> define the "class" EAttribute to be in the eKeys for that EReference.
>>>
>>> where the XML file is:
>>> <uiTemplate
>>> <classes
>>> <furniture
>>> <text class="furnText2" ...
>>> ...
>>>
>>> thanks in advance
>>>
>>> Luca
>>>
>
Re: EObject to XML [message #500266 is a reply to message #499912] Wed, 25 November 2009 14:23 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: luca_picello.mentor.com

Thanks Ed,
but isnt the xml-node-name equivalent specified in the ecore file
somewhere?
My idea is to parse the eObject until root and for each element get the
corrisponding xml-node name.
I believe it is an attribute of annotation from EAttribute or EReferences...
but cant fint it :-(

thanks in advance

Luca




"Ed Merks" <Ed.Merks@gmail.com> wrote in message
news:hegpgq$opq$1@build.eclipse.org...
> Luca,
>
> No, there's only direct support for producing URI fragments.
>
>
> Luca Picello wrote:
>> Thanks Ed,
>> adding ecore:keys="class" it works fine. Thank you.
>> Another question: is it possible to retrieve the XML-Xpath instead of the
>> EMF-Xpath ?
>>
>> Thank you in advance
>> Luca
>>
>>
>>
>> "Ed Merks" <Ed.Merks@gmail.com> wrote in message
>> news:hee6fs$uf9$3@build.eclipse.org...
>>>
>>>
>>> Luca Picello wrote:
>>>> Hallo folks,
>>>> I am wondering if and how I can extract the Xpath of an EObject which
>>>> refers to the nodes in the XML file.
>>>> But not specific to the emf-model, which is returned by
>>>> eObj.eResource().getURIFragment(eObj);
>>>>
>>>> "//@uiTemplate/@classes/@furnitureClasses/@textClasses.0" (returned by
>>>> getURIFragment)
>>>> but
>>>> "//@uiTemplate/@classes/@furniture/@text[class='furnText2']"
>>> In your Ecore model, on the "Funiture's" text containment EReference,
>>> define the "class" EAttribute to be in the eKeys for that EReference.
>>>>
>>>> where the XML file is:
>>>> <uiTemplate
>>>> <classes
>>>> <furniture
>>>> <text class="furnText2" ...
>>>> ...
>>>>
>>>> thanks in advance
>>>>
>>>> Luca
>>>>
>>
Re: EObject to XML [message #500277 is a reply to message #500266] Wed, 25 November 2009 14:42 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30653
Registered: July 2009
Senior Member
Luca,

Comments below.

Luca Picello wrote:
> Thanks Ed,
> but isnt the xml-node-name equivalent specified in the ecore file
> somewhere?
There's extended meta data, but not all models have that. In fact, some
models are serialized as XMI where references might be serialized as
either an element or an attribute.
> My idea is to parse the eObject until root and for each element get
> the corrisponding xml-node name.
You can try ExtendedMetaData.INSTANCE's APIs for getting this type of
information.
> I believe it is an attribute of annotation from EAttribute or
> EReferences... but cant fint it :-(
>
> thanks in advance
>
> Luca
>
>
>
>
> "Ed Merks" <Ed.Merks@gmail.com> wrote in message
> news:hegpgq$opq$1@build.eclipse.org...
>> Luca,
>>
>> No, there's only direct support for producing URI fragments.
>>
>>
>> Luca Picello wrote:
>>> Thanks Ed,
>>> adding ecore:keys="class" it works fine. Thank you.
>>> Another question: is it possible to retrieve the XML-Xpath instead
>>> of the EMF-Xpath ?
>>>
>>> Thank you in advance
>>> Luca
>>>
>>>
>>>
>>> "Ed Merks" <Ed.Merks@gmail.com> wrote in message
>>> news:hee6fs$uf9$3@build.eclipse.org...
>>>>
>>>>
>>>> Luca Picello wrote:
>>>>> Hallo folks,
>>>>> I am wondering if and how I can extract the Xpath of an EObject
>>>>> which refers to the nodes in the XML file.
>>>>> But not specific to the emf-model, which is returned by
>>>>> eObj.eResource().getURIFragment(eObj);
>>>>>
>>>>> "//@uiTemplate/@classes/@furnitureClasses/@textClasses.0"
>>>>> (returned by getURIFragment)
>>>>> but
>>>>> "//@uiTemplate/@classes/@furniture/@text[class='furnText2']"
>>>> In your Ecore model, on the "Funiture's" text containment
>>>> EReference, define the "class" EAttribute to be in the eKeys for
>>>> that EReference.
>>>>>
>>>>> where the XML file is:
>>>>> <uiTemplate
>>>>> <classes
>>>>> <furniture
>>>>> <text class="furnText2" ...
>>>>> ...
>>>>>
>>>>> thanks in advance
>>>>>
>>>>> Luca
>>>>>
>>>
>
Re: EObject to XML [message #500479 is a reply to message #500277] Thu, 26 November 2009 10:09 Go to previous message
Eclipse UserFriend
Originally posted by: luca_picello.mentor.com

Thank you Ed,

ResourceSet resourceSet = eObj.eResource().getResourceSet();
ExtendedMetaData extendedMetaData = new
BasicExtendedMetaData(resourceSet.getPackageRegistry());
EStructuralFeature eStructuralFeature = eObj.eContainingFeature();

String name = extendedMetaData.getName(eStructuralFeature);
System.out.println(name + " " + eObj);

works well.

Luca



"Ed Merks" <Ed.Merks@gmail.com> wrote in message
news:hejfor$llc$1@build.eclipse.org...
> Luca,
>
> Comments below.
>
> Luca Picello wrote:
>> Thanks Ed,
>> but isnt the xml-node-name equivalent specified in the ecore file
>> somewhere?
> There's extended meta data, but not all models have that. In fact, some
> models are serialized as XMI where references might be serialized as
> either an element or an attribute.
>> My idea is to parse the eObject until root and for each element get the
>> corrisponding xml-node name.
> You can try ExtendedMetaData.INSTANCE's APIs for getting this type of
> information.
>> I believe it is an attribute of annotation from EAttribute or
>> EReferences... but cant fint it :-(
>>
>> thanks in advance
>>
>> Luca
>>
>>
>>
>>
>> "Ed Merks" <Ed.Merks@gmail.com> wrote in message
>> news:hegpgq$opq$1@build.eclipse.org...
>>> Luca,
>>>
>>> No, there's only direct support for producing URI fragments.
>>>
>>>
>>> Luca Picello wrote:
>>>> Thanks Ed,
>>>> adding ecore:keys="class" it works fine. Thank you.
>>>> Another question: is it possible to retrieve the XML-Xpath instead of
>>>> the EMF-Xpath ?
>>>>
>>>> Thank you in advance
>>>> Luca
>>>>
>>>>
>>>>
>>>> "Ed Merks" <Ed.Merks@gmail.com> wrote in message
>>>> news:hee6fs$uf9$3@build.eclipse.org...
>>>>>
>>>>>
>>>>> Luca Picello wrote:
>>>>>> Hallo folks,
>>>>>> I am wondering if and how I can extract the Xpath of an EObject which
>>>>>> refers to the nodes in the XML file.
>>>>>> But not specific to the emf-model, which is returned by
>>>>>> eObj.eResource().getURIFragment(eObj);
>>>>>>
>>>>>> "//@uiTemplate/@classes/@furnitureClasses/@textClasses.0" (returned
>>>>>> by getURIFragment)
>>>>>> but
>>>>>> "//@uiTemplate/@classes/@furniture/@text[class='furnText2']"
>>>>> In your Ecore model, on the "Funiture's" text containment EReference,
>>>>> define the "class" EAttribute to be in the eKeys for that EReference.
>>>>>>
>>>>>> where the XML file is:
>>>>>> <uiTemplate
>>>>>> <classes
>>>>>> <furniture
>>>>>> <text class="furnText2" ...
>>>>>> ...
>>>>>>
>>>>>> thanks in advance
>>>>>>
>>>>>> Luca
>>>>>>
>>>>
>>
Previous Topic:[EMF Compare] Merging non-containment references
Next Topic:[CDO] Adding Tree-lock option to CDO editor.
Goto Forum:
  


Current Time: Thu Nov 21 18:39:35 GMT 2019

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

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

Back to the top