Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Export model to XMI with direct mapping, not by id
Export model to XMI with direct mapping, not by id [message #986502] Tue, 20 November 2012 16:36 Go to next message
Alexander Unsonamed is currently offline Alexander UnsonamedFriend
Messages: 10
Registered: October 2012
Junior Member
There is a Model 2 Model QVTo transformation which works pretty well.
After getting new Model I'd like to extract it to XMI, but there is a problem I have no idea how to address it.

For example there is a root element Box with children elements of type Box.
Besides, Box itself comprises refenerce to another class, e.g. Title.
Box = {child: Box, name:String, title: Title}
The problem is that I do get something like this:
<?xml version="1.0" encoding="UTF-8"?>
<xmi:XMI xmi:version="2.1" xmlns:xmi="ht_tp://schema.omg._org/spec/XMI/2.1" xmlns:mymodel="ht_tp://example._org/spec/MYMODEL/1.0">
 <mymodel:boxes xmi:id="uniqueId" name="RootBox" title="_YZAicjM3EeKpdar6P-33Hw">
     <mymodel:boxes xmi:id="uniqueId" name="ChildOne"/> 
 </mymodel:boxes> 
...
 <mymodel:Title xmi:id="_YZAicjM3EeKpdar6P-33Hw" expression="something" language="English"/>
...



But, I'd really like to remove mapping "by id" between Box and Title and get title element directly inside <mymodel:Box>. Is that possible?


By the time, I use options to for extracting to XMI:
...
Resource resource = resourceSet.createResource(fileURI);
...
Map options = new HashMap();
options.put(XMIResource.OPTION_USE_XMI_TYPE, Boolean.TRUE); 
options.put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.FALSE);
...
resource.save(options);

[Updated on: Tue, 20 November 2012 16:47]

Report message to a moderator

Re: Export model to XMI with direct mapping, not by id [message #986523 is a reply to message #986502] Tue, 20 November 2012 17:47 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 26237
Registered: July 2009
Senior Member
Alexander,

Comments below.

On 20/11/2012 5:36 PM, Alexander Unsonamed wrote:
> There is a Model 2 Model QVTo transformation which works pretty well.
> After getting new Model I'd like to extract it to XMI, but there is a
> problem I have no idea how to address it.
>
> For example there is a root element Box with children elements of type
> Box.
> Besides, Box itself comprises refenerce to another class, e.g. Title.
> Box = {child: Box, name:String, title: Title}
> The problem is that I do get something like this:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xmi:XMI xmi:version="2.1"
> xmlns:xmi="ht_tp://schema.omg._org/spec/XMI/2.1"
> xmlns:mymodel="ht_tp://example._org/spec/MYMODEL/1.0">
> <mymodel:boxes xmi:id="uniqueId" name="RootBox"
> title="_YZAicjM3EeKpdar6P-33Hw">
> <mymodel:boxes xmi:id="uniqueId" name="ChildOne"/> </boxes> ..
Two things with the same xsi:id; that can't be good.
> <mymodel:Title xmi:id="_YZAicjM3EeKpdar6P-33Hw" expression="something"
> language="English"/>
> ..
>
>
>
> But, I'd really like to remove mapping "by id" between Box and Title
> and get title element directly inside <mymodel:Box>.
Where is mymodel:Box?
> Is that possible?
You can make "title" a containment reference if you want that.
>
>
> By the time, I use options to for extracting to XMI:
>
> ..
> Resource resource = resourceSet.createResource(fileURI);
> ..
> Map options = new HashMap();
> options.put(XMIResource.OPTION_USE_XMI_TYPE, Boolean.TRUE);
> options.put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE,
> Boolean.FALSE);
> ..
> resource.save(options);
>
Re: Export model to XMI with direct mapping, not by id [message #986527 is a reply to message #986523] Tue, 20 November 2012 18:03 Go to previous messageGo to next message
Alexander Unsonamed is currently offline Alexander UnsonamedFriend
Messages: 10
Registered: October 2012
Junior Member
> "Two things with the same xsi:id; that can't be good."
I just simplified snippet as much as possible. Sure, both mymodel:boxes have their own uniquue xmi:idref.

> "You can make "title" a containment reference if you want that."
What does it mean? Could you provide the simplest example?
It would be nice, if I needed to change options only, like:
options.put(XMIResource.OPTION_USE_XMI_TYPE, Boolean.TRUE); 
Re: Export model to XMI with direct mapping, not by id [message #986540 is a reply to message #986527] Tue, 20 November 2012 20:35 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 26237
Registered: July 2009
Senior Member
Alexander,

In your Ecore model you must have a reference called "title" and it
sounds like you want its "containment" property to be true.

On 20/11/2012 7:03 PM, Alexander Unsonamed wrote:
>> "Two things with the same xsi:id; that can't be good."
> I just simplified snippet as much as possible. Sure, both
> mymodel:boxes have their own uniquue xmi:idref.
>
>> "You can make "title" a containment reference if you want that."
> What does it mean? Could you provide the simplest example?
> It would be nice, if I needed to change options only, like:
> options.put(XMIResource.OPTION_USE_XMI_TYPE, Boolean.TRUE);
Re: Export model to XMI with direct mapping, not by id [message #986628 is a reply to message #986540] Wed, 21 November 2012 09:06 Go to previous message
Alexander Unsonamed is currently offline Alexander UnsonamedFriend
Messages: 10
Registered: October 2012
Junior Member
Ed Merks,

It does work!
Thanks a lot.
Previous Topic:[EMF Compare] Which version for 4.3M3?
Next Topic:Target Definition and Unknown DB Adaptor: mysql
Goto Forum:
  


Current Time: Sat Nov 29 00:39:35 GMT 2014

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

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