|
|
Re: DanglingHREFException when saving Ecore model [message #424892 is a reply to message #424889] |
Sun, 09 November 2008 13:22 |
Ed Merks Messages: 33141 Registered: July 2009 |
Senior Member |
|
|
Derik,
Comments below.
Derek Palma wrote:
> I noticed that this XSD references another, so actually two EPackages
> are created.
One per namespace, yes.
> When I added the second EPackage to the ecoreResource, the exception
> no longer occurs, which makes complete sense.
Typically you'd put each in a separate resource.
>
> However, now I noticed an interesting thing. When I display the model
> in the model viewer I get two copies of the second namespace
> (EPackage). This is the one referenced from the out XSD. I must not be
> serializing the Ecore model correctly. (???)
It's hard to say without more details. Where are they appearing twice?
>
>
> "Derek Palma" <derek.palma@gmail.com> wrote in message
> news:gf5maq$1dp$1@build.eclipse.org...
>> Hi,
>>
>> I have written code to load an .xsd via XSDResourceFactoryImpl and
>> then convert it to an Ecore model with XSDEcoreBuilder. My last step
>> is to save the Ecore model so I don't have to rebuild it each time I
>> want to use it. I receive a DanglingHREFException with the code
>> below. I can imagine what this exception means, however, I am not
>> sure how to proceed since I really can't edit the original .xsd if
>> that is actually required in some cases. I hope that I am just using
>> the APIs incorrectly.
>>
>> EcoreResourceFactoryImpl ecoreResourceFactory = new
>> EcoreResourceFactoryImpl();
>>
>> Resource ecoreResource = ecoreResourceFactory.createResource(modelUri);
>>
>> ecoreResource.getContents().add(ePackage);
>>
>> ecoreResource.save(null);
Note that it's important you put all the packages in a resource before
you serialize any of them...
>>
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: DanglingHREFException when saving Ecore model [message #424893 is a reply to message #424892] |
Sun, 09 November 2008 14:56 |
Derek Palma Messages: 141 Registered: July 2009 |
Senior Member |
|
|
I think I committed a newbie mistake by not putting all ecore models into
the same ResourceSet before persisting any of them. Everything seems fine
now. Thanks for your help Ed!
Derek
"Ed Merks" <Ed.Merks@gmail.com> wrote in message
news:gf6o6e$egu$1@build.eclipse.org...
> Derik,
>
> Comments below.
>
> Derek Palma wrote:
>> I noticed that this XSD references another, so actually two EPackages are
>> created.
> One per namespace, yes.
>> When I added the second EPackage to the ecoreResource, the exception no
>> longer occurs, which makes complete sense.
> Typically you'd put each in a separate resource.
>>
>> However, now I noticed an interesting thing. When I display the model in
>> the model viewer I get two copies of the second namespace (EPackage).
>> This is the one referenced from the out XSD. I must not be serializing
>> the Ecore model correctly. (???)
> It's hard to say without more details. Where are they appearing twice?
>>
>>
>> "Derek Palma" <derek.palma@gmail.com> wrote in message
>> news:gf5maq$1dp$1@build.eclipse.org...
>>> Hi,
>>>
>>> I have written code to load an .xsd via XSDResourceFactoryImpl and then
>>> convert it to an Ecore model with XSDEcoreBuilder. My last step is to
>>> save the Ecore model so I don't have to rebuild it each time I want to
>>> use it. I receive a DanglingHREFException with the code below. I can
>>> imagine what this exception means, however, I am not sure how to proceed
>>> since I really can't edit the original .xsd if that is actually required
>>> in some cases. I hope that I am just using the APIs incorrectly.
>>>
>>> EcoreResourceFactoryImpl ecoreResourceFactory = new
>>> EcoreResourceFactoryImpl();
>>>
>>> Resource ecoreResource = ecoreResourceFactory.createResource(modelUri);
>>>
>>> ecoreResource.getContents().add(ePackage);
>>>
>>> ecoreResource.save(null);
> Note that it's important you put all the packages in a resource before you
> serialize any of them...
>>>
>>
|
|
|
Powered by
FUDForum. Page generated in 0.03197 seconds