|
Re: Cannot find eProxyURI: platform:/plugin/org.eclipse.xsd/model/XSD.ecore#//XSDSchema [message #868558 is a reply to message #868550] |
Wed, 02 May 2012 08:09 |
Ed Merks Messages: 33141 Registered: July 2009 |
Senior Member |
|
|
Comments below.
On 02/05/2012 9:51 AM, Tex Iano wrote:
> Hi,
>
> I am trying to use ATL in order to transform an XML document.
>
> When I try to load the corresponding XML schema
>
> metaModel = mh.createModelLoader().loadModel("MyXSD",
> mh.createModelLoader().getMOF(), metaModelUrl.openStream());
>
>
> I get:
> Resource for mailto:org.eclipse.emf.ecore.impl.EClassImpl@9830bc
> (eProxyURI:
> platform:/plugin/org.eclipse.xsd/model/XSD.ecore#//XSDSchema) is null;
> cannot be referenced
>
>
> I am using ATL programmatically, I want to embed it into an plain Java
> application, so I cannot use the Plugins.
> So, obviously when loading the XSD, EMF wants to access the XSD meta
> model and cannot find it. I have found the XSD.ecore. But my problem
> now is: How can I tell EMF to map
> platform:/plugin/org.eclipse.xsd/model/XSD.ecore#//XSDSchema to my
> local ecore file?
You can use
URI.createURI(XSDPlugin.INSTANCE.getBaseURL().toExternalForm()) to get
the location of the jar in which the model is contained and use that to
create a mapping from platform:/plugin/org.eclipse.xsd/ to that jar.
E.g., the following will load the model in a stand alone context:
public static void main(String[] args) throws Exception
{
ResourceSetImpl resourceSet = new ResourceSetImpl();
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("ecore",
new EcoreResourceFactoryImpl());
resourceSet.getURIConverter().getURIMap().put(URI.createPlatformPluginURI("/org.eclipse.xsd/",
true), URI.createURI(XSDPlugin.INSTANCE.getBaseURL().toExternalForm()));
Resource xsdEcoreResource =
resourceSet.getResource(URI.createPlatformPluginURI("/org.eclipse.xsd/model/XSD.ecore",
true), true);
xsdEcoreResource.save(System.out, null);
}
Note that the above uses a folder mapping so that everything referenced
below the bundle URI is redirected to the jar URI.
>
> Regards,
>
> Tex
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.03253 seconds