Absolute file path [message #716734] |
Thu, 18 August 2011 05:18  |
Eclipse User |
|
|
|
Hi everyone!
How can I get the absolute path of an resource?
I want to parse a WSDL file in the same directory as my own DSL file but the WSDL parser I am forced to use only accepts an absolute file path.
In the classes Resource, ResourceSet, URI etc. I wasn't ably to find anything that returns an absolute path.
Olaf
|
|
|
|
|
Re: Absolute file path [message #717558 is a reply to message #717551] |
Sun, 21 August 2011 06:20  |
Eclipse User |
|
|
|
Hi,
why is using the resource plugin a problem???
can you elaborate a bit how you execute your stuff???
how do you get the xtext models?
Why don't you simply ask the models for a file string?
sure you may have to wrap this into a new File(….) to
get an absolute path. but this should be no problem.
public static void main(String[] args) throws IOException {
Injector injector = new
MyDslStandaloneSetup().createInjectorAndDoEMFRegistration();
ResourceSet rs = injector.getInstance(ResourceSet.class);
URI uri = URI.createURI("../org.xtext.example.mydsl/src/Test.mydsl");
Resource r = rs.getResource(uri, true);
Model m = (Model) r.getContents().get(0);
String absolutePath = new
File(m.eResource().getURI().toFileString()).getCanonicalPath();
System.out.println(absolutePath);
}
BTW. this is an EMF question and not an Xtext question.
~Christian
On 2011-08-21 09:28:50 +0000, Olaf said:
> Hi,
>
> thank you, Timo, this will work for me!
>
> But just as a matter of interest: Is there a way to get the absolute
> path without using the resources plugin? Xtext claims that it may be
> used without any eclipse. And there are for sure use cases where you
> need an absolute path.
>
> Olaf
|
|
|
Powered by
FUDForum. Page generated in 0.04110 seconds