Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » XMI instance with HREFs only
XMI instance with HREFs only [message #1695055] Mon, 11 May 2015 15:52 Go to next message
Edoaurd Batot is currently offline Edoaurd BatotFriend
Messages: 91
Registered: March 2015
Member
Hi folks,

I'm trying to generate an Ecore instance and all I can get is this :

<?xml version="1.0" encoding="ASCII"?>
<OwnEcore:OMetaModel xmlns:OwnEcore="OwnEcore">
  <classes href="out/test.xml#/1"/>
  <datatypes href="out/test.xml#/9"/>
  <datatypes href="out/test.xml#/10"/>
  <datatypes href="out/test.xml#/18"/>
</OwnEcore:OMetaModel>


It is to note that the resource.getContents() contains more than one elements.
Also, to fill the StructuralReferences, I use either

EList<EObject> list = (EList<EObject>)source.eGet(or.getEreference(), false);
list.add(eo);

or

source.eSet(or.getEreference(), eo);

both give the same result.

Any clue ?
Re: XMI instance with HREFs only [message #1695059 is a reply to message #1695055] Mon, 11 May 2015 16:37 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30544
Registered: July 2009
Senior Member
Edoaurd,

Comments below.

On 11/05/2015 5:52 PM, Edoaurd Batot wrote:
> Hi folks,
>
> I'm trying to generate an Ecore instance and all I can get is this :
> <?xml version="1.0" encoding="ASCII"?>
> <OwnEcore:OMetaModel xmlns:OwnEcore="OwnEcore">
> <classes href="out/test.xml#/1"/>
> <datatypes href="out/test.xml#/9"/>
> <datatypes href="out/test.xml#/10"/>
> <datatypes href="out/test.xml#/18"/>
> </OwnEcore:OMetaModel>
>
> It is to note that the resource.getContents() contains more than one
> elements.
But it's not an XMIResourceImpl and only that will serialize more than
one element.
> Also, to fill the StructuralReferences, I use either
> EList<EObject> list =
> (EList<EObject>)source.eGet(or.getEreference(), false);
> list.add(eo);
>
> or
>
> source.eSet(or.getEreference(), eo);
And or is what?
>
> both give the same result.
I doubt it. If you use eSet on a multiple valued value, the value must
be a list....
>
> Any clue ?
Not enough information provide...
Re: XMI instance with HREFs only [message #1695063 is a reply to message #1695059] Mon, 11 May 2015 17:06 Go to previous messageGo to next message
Edoaurd Batot is currently offline Edoaurd BatotFriend
Messages: 91
Registered: March 2015
Member
Thanks Ed,

to be more concise, I add element to the list provided by eGet when applicable and I do an eSet otherwise. And I mean that both do the same (one on a list, the other on a single element) as they put a HREF in the resource.

I've tryed using XMIResourceImpl too, but it throws a NullPointer :
Exception in thread "main" java.lang.NullPointerException
at org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.getHREF(XMLHelperImpl.java:808)

The HREF keeps bothering.

For any further precision, just ask.

PS : oups, "or" is a wrapper I use to generate the structure. It contains the EStructuralFeature : or.getEReference().
And "eo" is the OBject to insert.

[Updated on: Mon, 11 May 2015 17:10]

Report message to a moderator

Re: XMI instance with HREFs only [message #1695075 is a reply to message #1695063] Mon, 11 May 2015 20:23 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30544
Registered: July 2009
Senior Member
Edoaurd,

Comments below.

On 11/05/2015 7:06 PM, Edoaurd Batot wrote:
> Thanks Ed,
>
> to be more concise, I add element to the list provided by eGet when
> applicable and I do an eSet otherwise.
Yes. But of course I already know that, so I guess there is no question
in this regard...
> And I mean that both do the same (one on a list, the other on a single
> element)
Yes.
> as they put a HREF in the resource.
This doesn't parse for me.
>
> I've tryed using XMIResourceImpl too, but it throws a NullPointer :
> Exception in thread "main" java.lang.NullPointerException
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.getHREF(XMLHelperImpl.java:808)
That doesn't match a line number in EMF 2.11.
>
> The HREF keeps bothering.
This also doesn't parse.
>
> For any further precision, just ask.
You're the one with questions, but there are no question marks in this
post, so presumably you ran out of questions....
Re: XMI instance with HREFs only [message #1695080 is a reply to message #1695075] Mon, 11 May 2015 20:52 Go to previous messageGo to next message
Edoaurd Batot is currently offline Edoaurd BatotFriend
Messages: 91
Registered: March 2015
Member
How to get rid of the HREF and have the targeted links contained in the XML element instead ?
<?xml version="1.0" encoding="ASCII"?>
<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:FeatureDiagram="FeatureDiagram">
  <FeatureDiagram:Or/>
  <FeatureDiagram:And>
    <owningFeature href="#/4"/>
  </FeatureDiagram:And>
  <FeatureDiagram:Feature name="EString35" optional="true">
    <parent href="#/3"/>
    <operators xsi:type="FeatureDiagram:Or" href="#/0"/>
  </FeatureDiagram:Feature>
  <FeatureDiagram:PrimitiveFeature name="EString5">
    <children href="#/2"/>
    <operators xsi:type="FeatureDiagram:And" href="#/1"/>
  </FeatureDiagram:PrimitiveFeature>
  <FeatureDiagram:PrimitiveFeature name="EString35"/>
</xmi:XMI>



And the line number, might be erroneous, but the exception pops from method getHREF() anyway.
The throwing instruction must be objectURI.toString(); where objectURI is null.

[Updated on: Mon, 11 May 2015 21:16]

Report message to a moderator

Re: XMI instance with HREFs only [message #1695096 is a reply to message #1695080] Tue, 12 May 2015 04:36 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30544
Registered: July 2009
Senior Member
Edoaurd,

Using
org.eclipse.emf.ecore.xmi.XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE
set to true (best done in your resource factory), might give you more
like what you want. Failing that, you'd best write your model as an XML
Schema that specifies exactly how you want the XML to look, look at the
extended metadata annotations set on the resulting Ecore model, and
apply those to your original model (as well as modify your resource
factory to use the options you'll see generated for an XML Schema-based
model).


On 11/05/2015 10:52 PM, Edoaurd Batot wrote:
> How to get rid of the HREF and have the targeted links contained in
> the XML element instead ?
> <?xml version="1.0" encoding="ASCII"?>
> <xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:FeatureDiagram="FeatureDiagram">
> <FeatureDiagram:Or/>
> <FeatureDiagram:And>
> <owningFeature href="#/4"/>
> </FeatureDiagram:And>
> <FeatureDiagram:Feature name="EString35" optional="true">
> <parent href="#/3"/>
> <operators xsi:type="FeatureDiagram:Or" href="#/0"/>
> </FeatureDiagram:Feature>
> <FeatureDiagram:PrimitiveFeature name="EString5">
> <children href="#/2"/>
> <operators xsi:type="FeatureDiagram:And" href="#/1"/>
> </FeatureDiagram:PrimitiveFeature>
> <FeatureDiagram:PrimitiveFeature name="EString35"/>
> </xmi:XMI>
>
>
>
Re: XMI instance with HREFs only [message #1695462 is a reply to message #1695096] Thu, 14 May 2015 22:05 Go to previous messageGo to next message
Edoaurd Batot is currently offline Edoaurd BatotFriend
Messages: 91
Registered: March 2015
Member
Thanks for he reply, but the otpion doesn't help.
But I guess something else must wrong as the simplest test case can't be open anymore.
Look at that model, why Eclipse refuse to open it ? I mean, tries hard, fills the stack, and explodes.
<?xml version="1.0" encoding="ASCII"?>
<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:FeatureDiagram="FeatureDiagram">
  <FeatureDiagram:And owningFeature="#/2" features="#/2">
    <enum>lit_1</enum>
    <enum>lit_0</enum>
    <testON>0.15720427</testON>
    <testON>0.73726165</testON>
    <testON>0.93219703</testON>
  </FeatureDiagram:And>
  <FeatureDiagram:Feature name="EString386" optional="true">
    <parent href="#/2"/>
    <children href="#/1"/>
    <operators xsi:type="FeatureDiagram:And" href="#/0"/>
  </FeatureDiagram:Feature>
  <FeatureDiagram:PrimitiveFeature name="EString686"/>
</xmi:XMI>

I build the model randomly from the Ecore specification. I assure the model is valid as I print it in other formats that give results.

Another point :
Look at the last line of the model : I applied an eSet (right EStructuralFeature with its right EObject (or list) as with other references) but it stays empty.
Is there any condition which could restraint silently from setting an EReference ?


Quelque chose m'├ęchappe...
Re: XMI instance with HREFs only [message #1695483 is a reply to message #1695462] Fri, 15 May 2015 08:14 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 30544
Registered: July 2009
Senior Member
Comments below.


On 15/05/2015 12:05 AM, Edoaurd Batot wrote:
> Thanks for he reply, but the otpion doesn't help.
It has no impact on serialization at all?
> But I guess something else must wrong as the simplest test case can't
> be open anymore.
I guess I must guess too.
> Look at that model, why Eclipse refuse to open it ? I mean, tries
> hard, fills the stack, and explodes.
And I should just at the nature of these symptoms?
> <?xml version="1.0" encoding="ASCII"?>
> <xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:FeatureDiagram="FeatureDiagram">
> <FeatureDiagram:And owningFeature="#/2" features="#/2">
> <enum>lit_1</enum>
> <enum>lit_0</enum>
> <testON>0.15720427</testON>
> <testON>0.73726165</testON>
> <testON>0.93219703</testON>
> </FeatureDiagram:And>
> <FeatureDiagram:Feature name="EString386" optional="true">
> <parent href="#/2"/>
> <children href="#/1"/>
> <operators xsi:type="FeatureDiagram:And" href="#/0"/>
> </FeatureDiagram:Feature>
> <FeatureDiagram:PrimitiveFeature name="EString686"/>
> </xmi:XMI>
>
> I build the model randomly from the Ecore specification. I assure the
> model is valid as I print it in other formats that give results.
>
> Another point :
> Look at the last line of the model : I applied an eSet (right
> EStructuralFeature with its right EObject (or list) as with other
> references) but it stays empty. Is there any condition which could
> restraint silently from setting an EReference ?
A dangling reference.
>
>
> Quelque chose m'├ęchappe...
Previous Topic:How to force EMF not to manipulate reference ids
Next Topic:[xcore] Lockup on entering date on dynamic instance
Goto Forum:
  


Current Time: Tue Oct 15 12:21:34 GMT 2019

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

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

Back to the top