EObject to XML [message #499580] |
Mon, 23 November 2009 06:57  |
Eclipse User |
|
|
|
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 #500277 is a reply to message #500266] |
Wed, 25 November 2009 09:42   |
Eclipse User |
|
|
|
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 05:09  |
Eclipse User |
|
|
|
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
>>>>>>
>>>>
>>
|
|
|
Powered by
FUDForum. Page generated in 0.06845 seconds