Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Issue to load XML file provide with Edapt example project(Cannot load a basic XML file.)
Issue to load XML file provide with Edapt example project [message #1454435] Tue, 28 October 2014 11:40 Go to next message
Sylvain Bortelle is currently offline Sylvain BortelleFriend
Messages: 5
Registered: October 2014
Junior Member
Hello,

I got Edapt project from GIT and I imported project given an example, especially:
- library
- library.edit
- library.editor
- library.example

I'd like to write a basic class that read the XML file (Example.library) given in example. So I created a new project call: library.mytest.

That is a part of my Main file:
LibraryPackage.eINSTANCE.eClass();

ResourceSet resourceSet = new ResourceSetImpl();
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("library", new XMLResourceFactoryImpl());

Resource resource = resourceSet.getResource(URI.createFileURI(xmlFilePath), true);


Unfortunately, I have this error:
Package with uri 'http : // library/v1' not found.

I don't understand what I do wrong.

After some research may be my mistake can come from plugin.xml file. I don't know what to put in, so it's empty.

Thank you in advance for your help.

[Updated on: Sat, 01 November 2014 18:30]

Report message to a moderator

Re: Can't use [message #1454676 is a reply to message #1454435] Tue, 28 October 2014 16:50 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33136
Registered: July 2009
Senior Member
Sylvain,

Comments below.

On 28/10/2014 4:16 PM, Sylvain Bortelle wrote:
> Hello,
>
> I got Edapt project from GIT and I imported project given an example,
> especially:
> - library
> - library.edit
> - library.editor
> - library.example
>
> I'd like to write a basic class that read the XML file
> (Example.library) given in example. So I created a new project call:
> library.mytest.
>
> That is a part of my Main file:
>
> LibraryPackage.eINSTANCE.eClass();
>
> ResourceSet resourceSet = new ResourceSetImpl();
> resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("library",
> new XMLResourceFactoryImpl());
>
> Resource resource =
> resourceSet.getResource(URI.createFileURI(xmlFilePath), true);
Note that the generated library.xml has an XyzExample.java. It should
work out of the box. Doesn't it?
>
>
> Unfortunately, I have this error:
> Package with uri 'http : // library/v1' not found.
Where did the resource come from? What's the nsURI of your LibraryPackage?
>
> I don't understand what I do wrong.
>
> After some research may be my mistake can come from plugin.xml file. I
> don't know what to put in, so it's empty.
Normally one is generated in the plugin.xml of the model, but if you're
running stand alone, such plugin.xml registrations don't have any impact...
>
> Thank you in advance for your help.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Can't use [message #1455341 is a reply to message #1454676] Wed, 29 October 2014 09:07 Go to previous messageGo to next message
Sylvain Bortelle is currently offline Sylvain BortelleFriend
Messages: 5
Registered: October 2014
Junior Member
Hello Ed,

Thank you for your help.

Quote:

Note that the generated library.xml has an XyzExample.java. It should
work out of the box. Doesn't it?

Didn't see any README or main() function for use this project out of the box. So I assumed this example is a functional API and to use it, we should implement a main function.

Quote:

Where did the resource come from? What's the nsURI of your LibraryPackage?

For me, the resource is the XML file to be loaded: it's something like this (relative path): "./xml/Example.library".
Concerning the namespaceURI of LibraryPackage it's: http : // library/v2. So you are right I have a difference between API generated (by EMF I guess) and the XML file given in example. But it's an example provide by Edapt to show migration model...

Quote:

Normally one is generated in the plugin.xml of the model, but if you're
running stand alone, such plugin.xml registrations don't have any impact...

Ok.

I think I use the wrong project to explore EMF possibility. I will try to get another basic example.

Re thank you and Good day.
Re: Can't use [message #1455628 is a reply to message #1455341] Wed, 29 October 2014 15:20 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33136
Registered: July 2009
Senior Member
Sylvain,

Comments below.

On 29/10/2014 10:07 AM, Sylvain Bortelle wrote:
> Hello Ed,
>
> Thank you for your help.
>
> Quote:
>> Note that the generated library.xml has an XyzExample.java. It should
>> work out of the box. Doesn't it?
>
> Didn't see any README or main() function for use this project out of
> the box.
Yes, in your case is probably LibraryExample.java and it has a main. It
is just an example of how to use your generated model in a stand-alone
context.
> So I assumed this example is a functional API and to use it, we should
> implement a main function.
>
> Quote:
>> Where did the resource come from? What's the nsURI of your
>> LibraryPackage?
>
> For me, the resource is the XML file to be loaded: it's something like
> this (relative path): "./xml/Example.library".
It's generally a bad idea to load with anything other than an absolute
URI; the problem is that relative references within the loaded resource
won't resolve properly. So you'll see the generated example uses
File.getAbsolutePath for what it passed to URI.createFileURI...
> Concerning the namespaceURI of LibraryPackage it's: http : //
> library/v2. So you are right I have a difference between API generated
> (by EMF I guess)
Yes.
> and the XML file given in example.
So the XML doesn't conform to the model you're trying to use. That just
doesn't work.
> But it's an example provide by Edapt to show migration model...
Did they provide the example model implementation too?
>
> Quote:
>> Normally one is generated in the plugin.xml of the model, but if you're
>> running stand alone, such plugin.xml registrations don't have any
>> impact...
>
> Ok.
>
> I think I use the wrong project to explore EMF possibility. I will try
> to get another basic example.
Okay.
>
> Re thank you and Good day.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Issue to load XML file provide with Edapt example project [message #1455675 is a reply to message #1455628] Wed, 29 October 2014 16:32 Go to previous message
Sylvain Bortelle is currently offline Sylvain BortelleFriend
Messages: 5
Registered: October 2014
Junior Member
Thank you for your attention.

Quote:

Yes, in your case is probably LibraryExample.java and it has a main. It
is just an example of how to use your generated model in a stand-alone
context.

Yes you are right. Resource present on GIT are just a basic entry point for introduce Edapt functionality. And I guess a little practice of EMF technology was needed.

Quote:

It's generally a bad idea to load with anything other than an absolute
URI; the problem is that relative references within the loaded resource
won't resolve properly. So you'll see the generated example uses
File.getAbsolutePath for what it passed to URI.createFileURI...

Ok, I will take note of that.

Quote:

So the XML doesn't conform to the model you're trying to use. That just
doesn't work.

Yes, after aligning Model and implementation of Model it's better.

Quote:

Did they provide the example model implementation too?

I have just found the XML for Model version 1. But the goal of this example is to show how load an old XML with a new Model with Edapt process. So I must certainly to create the XML v2 myself.

edit: I found the correct button to edit post.
ps : if a kind moderator can change the title of this topic to clarify it, by: "Issue to load XML file provide with Edapt example project" for example, it would be nice. I haven't found functionality to do this.

[Updated on: Sat, 01 November 2014 18:32]

Report message to a moderator

Previous Topic:[EMF + CDO] Strategy for restricting duplicate EAttributes values
Next Topic:[EMF] load an XML stream, how to resolve the factory
Goto Forum:
  


Current Time: Fri Apr 19 04:15:46 GMT 2024

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

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

Back to the top