Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » Problems loading XSD in standalone transformation
Problems loading XSD in standalone transformation [message #1751492] Tue, 10 January 2017 18:34 Go to next message
Aubrey Mising name is currently offline Aubrey Mising nameFriend
Messages: 6
Registered: January 2010
Junior Member
Hi,
I am working in an standalone transformation that uses as input an XML backed with an XMLSchema. My code is based on "org.eclipse.epsilon.eunit.examples.etl", so my models and metamodels are placed in a source code folder with the packages models and metamodels.

I have tried several things with no success.

Attempt 1:
I copy this section of code of the thread [1]:
             StringProperties sp = new StringProperties();
			sp.put(XmlModel.PROPERTY_NAME, name);
			sp.put(XmlModel.PROPERTY_READONLOAD, readOnLoad);
			sp.put(XmlModel.PROPERTY_STOREONDISPOSAL, storeOnDisposal);
			sp.put(XmlModel.PROPERTY_XSD_FILE,getResourceEmfURI(metamodelPath).toFileString());
			sp.put(XmlModel.PROPERTY_MODEL_FILE,getResourceEmfURI(modelPath).toFileString());
			xmlModel.load(sp, (IRelativePathResolver)null);


The code of the method getResourceEmfURI is:
private URI getResourceEmfURI(String resourcePath) {
		URI res=URI.createURI(getClass().getResource(
				RESOURCE_PATH_PREFIX + resourcePath).toExternalForm());
		System.out.println(res.toFileString());
		
		return res;
	}


and I got the following exception:
java.lang.NullPointerException
at org.eclipse.epsilon.emc.emf.xml.XmlModel.load(XmlModel.java:40)
at org.eclipse.opencert.epfimport.standalone.EPFTransformation.loadXMLModel(EPFTransformation.java:46)
at org.eclipse.opencert.epfimport.standalone.RunTransformation.main(RunTransformation.java:11)

which is caused by the fact that the IRelativePathResolver is null. However, I do not know about any implementation of this interface.

Attempt 2
My second attempt has been directly inspired by the standalone examples of the mentioned example and it is as follows:

                        xmlModel.setName(name);
			xmlModel.setMetamodelFileUri(getResourceEmfURI(metamodelPath));
			xmlModel.setModelFileUri(getResourceEmfURI(modelPath));
			xmlModel.setReadOnLoad(readOnLoad);
			xmlModel.setStoredOnDisposal(storeOnDisposal);
			xmlModel.load();


and I got the following exception:
Internal error: org.eclipse.emf.ecore.resource.Resource$IOWrappedException: Class 'schema' is not found or is abstract. [file:/G:/*****/bin/metamodels/EPFSchema.xsd, 3, 162]

Do you have any idea about how to resolve this?

[1]http://www.eclipse.org/forums/index.php?t=msg&&th=153856&goto=484564
Re: Problems loading XSD in standalone transformation [message #1751530 is a reply to message #1751492] Wed, 11 January 2017 08:47 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2162
Registered: July 2009
Location: York, UK
Senior Member

Hi,

Nothing comes to mind off the top of my head I'm afraid. Could you please provide a minimal example [1] we can use to reproduce this?

Cheers,
Dimitris

[1] https://www.eclipse.org/epsilon/doc/articles/minimal-examples
Re: Problems loading XSD in standalone transformation [message #1751538 is a reply to message #1751530] Wed, 11 January 2017 10:03 Go to previous messageGo to next message
Aubrey Mising name is currently offline Aubrey Mising nameFriend
Messages: 6
Registered: January 2010
Junior Member
Hi Dimitris,
Please find attached the minimal example.

Regards,

[Updated on: Wed, 11 January 2017 14:27]

Report message to a moderator

Re: Problems loading XSD in standalone transformation [message #1751539 is a reply to message #1751538] Wed, 11 January 2017 10:23 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2162
Registered: July 2009
Location: York, UK
Senior Member

Hi,

Replacing "xmlModel.load(sp, (IRelativePathResolver)null);" in attempt1 with the following should do the trick.

xmlModel.load(sp, new IRelativePathResolver() {
    @Override
    public String resolve(String relativePath) {
        return relativePath;
    }
});


Cheers,
Dimitris
Re: Problems loading XSD in standalone transformation [message #1751543 is a reply to message #1751539] Wed, 11 January 2017 10:31 Go to previous message
Aubrey Mising name is currently offline Aubrey Mising nameFriend
Messages: 6
Registered: January 2010
Junior Member
Hi,
It works!

Many thanks for this.

Regards,

Aubrey
Previous Topic:return substring
Next Topic:How to implement rules to a connector
Goto Forum:
  


Current Time: Fri Apr 19 02:43:46 GMT 2024

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

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

Back to the top