Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » How to serialze intrinsic ids as attributes?
How to serialze intrinsic ids as attributes? [message #1488065] Wed, 26 November 2014 09:33 Go to next message
Jan Rosczak is currently offline Jan RosczakFriend
Messages: 53
Registered: July 2009
Location: Hamburg, Germany
Member
Hello,

I am trying to convert a legacy xml format into an EMF model.
The one problem I face is serializing local references. I have conditions which can reference other conditions.

EMF would serialize this as:
<condition varName="cond1"/>
<condition varName="cond2">
  <condition>cond1</condition>
</condition>


But I need to parse something like that:
<condition varName="cond1"/>
<condition varName="cond2">
  <condition vaName="cond1"/>
</condition>


Is there a way to tell EMF to store a reference not as content of an element but as an attribute of that element?

Thanks
Jan R.
Re: How to serialze intrinsic ids as attributes? [message #1488079 is a reply to message #1488065] Wed, 26 November 2014 09:48 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30141
Registered: July 2009
Senior Member
Jan,

Comments below.

On 26/11/2014 10:33 AM, Jan Rosczak wrote:
> Hello,
>
> I am trying to convert a legacy xml format into an EMF model.
> The one problem I face is serializing local references. I have
> conditions which can reference other conditions.
>
> EMF would serialize this as:
>
> <condition varName="cond1"/>
> <condition varName="cond2">
> <condition>cond1</condition>
> </condition>
That seems surprising. Is this using an XMIResourceImpl?
>
>
> But I need to parse something like that:
>
> <condition varName="cond1"/>
> <condition varName="cond2">
> <condition vaName="cond1"/>
That will be a challenge. I doubt the legacy format itself was defined
with XML Schema...
> </condition>
>
>
> Is there a way to tell EMF to store a reference not as content of an
> element but as an attribute of that element?
org.eclipse.emf.ecore.xmi.XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE
though I have to wonder what options you've set that's making it
serialize this way. It's not what I'd expect by default (for an XMI
serialization). If you're using an XML serialization using a resource
factory like the one generated for an XML Schema-based model, an
extended metadata annotation for the reference feature as produced by
org.eclipse.emf.ecore.util.ExtendedMetaData.setFeatureKind(EStructuralFeature,
int) with org.eclipse.emf.ecore.util.ExtendedMetaData.ELEMENT_FEATURE
should do the trick, but the serialization you show above would need
specialized code to handle and produce...
>
> Thanks
> Jan R.
Re: How to serialze intrinsic ids as attributes? [message #1488084 is a reply to message #1488079] Wed, 26 November 2014 09:53 Go to previous messageGo to next message
Jan Rosczak is currently offline Jan RosczakFriend
Messages: 53
Registered: July 2009
Location: Hamburg, Germany
Member
Yes, sorry forget to mention that I use ExtendedMetaData and a XMLResource.
Re: How to serialze intrinsic ids as attributes? [message #1496767 is a reply to message #1488084] Wed, 03 December 2014 08:54 Go to previous message
Jan Rosczak is currently offline Jan RosczakFriend
Messages: 53
Registered: July 2009
Location: Hamburg, Germany
Member
I partly solved my problem by using a ResourceHandler to process my objects before save and after loading.
Previous Topic:EMF command redo returns uncomplete Graphiti diagram
Next Topic:Can't Steer EType from XSD: Type vs Type1 vs Type2 Problems
Goto Forum:
  


Current Time: Mon May 27 05:36:00 GMT 2019

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

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

Back to the top