Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » MWE: Caching XML Schema to ECORE transformation(Howto generate ecore from XML schema)
MWE: Caching XML Schema to ECORE transformation [message #815962] Thu, 08 March 2012 09:09 Go to next message
Florian Reischl is currently offline Florian ReischlFriend
Messages: 5
Registered: February 2012
Junior Member
Hi,

we generate Java code from XML. The XML model is specified by a complex XML schema definition. When the MWE template is executed it loads the XML schema which lasts about one minute. In fact the MWE runtime currently generates the internal ECORE representation from the XML schema definition prior to executing any XPand templates. To speed up execution time we would like to generate the ecore model once and use it directly for XPand template execution.

Thanx
Re: MWE: Caching XML Schema to ECORE transformation [message #824105 is a reply to message #815962] Mon, 19 March 2012 09:07 Go to previous messageGo to next message
Florian Reischl is currently offline Florian ReischlFriend
Messages: 5
Registered: February 2012
Junior Member
Hi,

I found an easy way to generate Ecore from XML Schema (XSD) using Eclipse. Now I'd like to use those Ecore files within my workflow to generate code from XML files specified by the XML Schema, i.e. the XML files are not compatible with XMI as expected by the XMIReader. My question is, how can I manage to read the XML files using the Ecore files.

Here is the workflow I use:

<workflow> 	
	<bean class="org.eclipse.emf.mwe.utils.StandaloneSetup" >
            <registerEcoreFile value="model/test.ecore" />
	</bean>

	<component class="org.eclipse.emf.mwe.utils.Reader">
		<uri value="test.xml" />
		<modelSlot value="model" />
	</component>

	<component class="org.eclipse.xpand2.Generator">
		<fileEncoding value="UTF-8"/>
		<metaModel  class="org.eclipse.xtend.typesystem.emf.EmfRegistryMetaModel"/>
		<expand value="icd_structure::Root FOR model" />
		<outlet path="out" overwrite="true"/>
	</component>
</workflow>


When I run it I get the following error:

19.03.2012 09:56:13 org.eclipse.emf.mwe.core.WorkflowEngine prepare
INFO: 
--------------------------------------------------------------------------------------
19.03.2012 09:56:13 org.eclipse.emf.mwe.core.WorkflowEngine prepare
INFO: EMF Modeling Workflow Engine 1.1.1, Build v201108020506
19.03.2012 09:56:13 org.eclipse.emf.mwe.core.WorkflowEngine prepare
INFO: (c) 2005-2009 openarchitectureware.org and contributors
19.03.2012 09:56:13 org.eclipse.emf.mwe.core.WorkflowEngine prepare
INFO: 
--------------------------------------------------------------------------------------
19.03.2012 09:56:13 org.eclipse.emf.mwe.core.WorkflowEngine prepare
INFO: running workflow: 
/home/xxx/git/test/workflows/ecore.mwe
19.03.2012 09:56:13 org.eclipse.emf.mwe.core.WorkflowEngine prepare
INFO:
19.03.2012 09:56:14 org.eclipse.emf.mwe.utils.StandaloneSetup setPlatformUri
INFO: Registering platform uri '/home/xxx/git/test'
19.03.2012 09:56:14 org.eclipse.emf.mwe.utils.StandaloneSetup registerPackage
INFO: Adding dynamic EPackage 'www.test.de/2011/07/element'; from 
'model/test.ecore'
19.03.2012 09:56:14 org.eclipse.emf.mwe.core.container.CompositeComponent internalInvoke
INFO: Reader: Loading model from test.xml
19.03.2012 09:56:14 org.eclipse.emf.mwe.core.WorkflowEngine executeWorkflow
SCHWERWIEGEND: Workflow interrupted. Reason: Couldn't load resource under test.xml : 
org.eclipse.emf.ecore.xmi.ClassNotFoundException: Class 'element' is not found or is 
abstract. 
(file:///.../test.xml, 
2, 52)


The XML file contains an top-level "element". The error message indicates that "element" can not be associated with the particular Ecore "element". How can I get it to work?
Re: MWE: Caching XML Schema to ECORE transformation [message #824185 is a reply to message #824105] Mon, 19 March 2012 11:12 Go to previous messageGo to next message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 762
Registered: July 2009
Location: Dortmund, Germany
Senior Member

As you said, your XML files are specified by the XSD schema and NOT by the Ecore file. You can read directly those XML files using the XSD reader and the XSD metamodel. Otherwise your XML files must be compatible to EMF XMI, and this is actually what you don't want.

Look at the XSD examples from Xpand, e.g.
http://git.eclipse.org/c/m2t/org.eclipse.xpand.git/tree/examples/org.eclipse.xpand.examples.xsd.m2m.xml2svg/src/xsd/m2m/xml2svg/xml2svg.oaw

Regards,
~Karsten


Need professional support for Xtext, EMF, Eclipse IDE?
Go to: http://devhub.karakun.com
Twitter : @kthoms
Blog : www.karsten-thoms.de
Re: MWE: Caching XML Schema to ECORE transformation [message #824203 is a reply to message #824185] Mon, 19 March 2012 11:44 Go to previous messageGo to next message
Florian Reischl is currently offline Florian ReischlFriend
Messages: 5
Registered: February 2012
Junior Member
Karsten Thoms wrote on Mon, 19 March 2012 07:12
As you said, your XML files are specified by the XSD schema and NOT by the Ecore file. You can read directly those XML files using the XSD reader and the XSD metamodel. Otherwise your XML files must be compatible to EMF XMI, and this is actually what you don't want.

This works fine but as I mentioned in the initial post this is very slow. The problem is that the XSDMetaModel builds on-the-fly an Ecore representation from the XSD files used. My initial Question was and actually is how can I speedup the process. Maybe it is possible to generate the Ecore-Model once and just use it instead of the XSD files.
Re: MWE: Caching XML Schema to ECORE transformation [message #824220 is a reply to message #824203] Mon, 19 March 2012 11:56 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.emf.doc%2Ftutorials%2Fxlibmod%2Fxlibmod.html

On 19/03/2012 12:44 PM, Florian Reischl wrote:
> Karsten Thoms wrote on Mon, 19 March 2012 07:12
>> As you said, your XML files are specified by the XSD schema and NOT
>> by the Ecore file. You can read directly those XML files using the
>> XSD reader and the XSD metamodel. Otherwise your XML files must be
>> compatible to EMF XMI, and this is actually what you don't want.
>
> This works fine but as I mentioned in the initial post this is very
> slow. The problem is that the XSDMetaModel builds on-the-fly an Ecore
> representation from the XSD files used. My initial Question was and
> actually is how can I speedup the process. Maybe it is possible to
> generate the Ecore-Model once and just use it instead of the XSD files.
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: MWE: Caching XML Schema to ECORE transformation [message #824239 is a reply to message #824220] Mon, 19 March 2012 12:31 Go to previous message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 762
Registered: July 2009
Location: Dortmund, Germany
Senior Member

I'm not sure how exactly, but somehow it will be possible. Did you try to register the generated EPackages to StandaloneSetup?

Need professional support for Xtext, EMF, Eclipse IDE?
Go to: http://devhub.karakun.com
Twitter : @kthoms
Blog : www.karsten-thoms.de
Previous Topic:existing acceleo templates for java code generation
Next Topic:[Acceleo] OO-semantics of templates
Goto Forum:
  


Current Time: Thu Apr 25 07:07:09 GMT 2024

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

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

Back to the top