Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » xpand
xpand [message #671295] Tue, 17 May 2011 12:26 Go to next message
khalil  is currently offline khalil Friend
Messages: 11
Registered: May 2011
Junior Member
hi everyone

I am trying to use xpand to generate a code from an xmi model conform to an metamodels ecore the name of my model is VHDL and the name of my metamodels MetaVHDL
I begin to use xpand but I can't configure the workflow to run the file, if someone explain me how to do, and for more details I can add more. thanks
Re: xpand [message #671371 is a reply to message #671295] Tue, 17 May 2011 16:13 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14664
Registered: July 2009
Senior Member
Hi,

did you have a look at the sample created with the xpand wizard. it does basically exact that for another ecore.

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: xpand [message #671389 is a reply to message #671371] Tue, 17 May 2011 17:41 Go to previous messageGo to next message
khalil  is currently offline khalil Friend
Messages: 11
Registered: May 2011
Junior Member
hi
i have only de the documentations of oaw and the exemple of the book
Re: xpand [message #671426 is a reply to message #671389] Tue, 17 May 2011 20:46 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14664
Registered: July 2009
Senior Member
Hi,

i do not really know how to help you. there are the docs with a tutorial, the wizard creates an example.

here is the workflow (Eclipse Xpand 1.0.x - in oAW 4.3.1 the classnames are a bit different)
<?xml version="1.0"?>
<workflow>
	<property name="model" value="my.generator.project/src/Model.xmi" />
	<property name="src-gen" value="src-gen" />
	
	<!-- set up EMF for standalone execution -->
	<bean class="org.eclipse.emf.mwe.utils.StandaloneSetup" >
		<platformUri value=".."/>
	</bean>
	
	<!-- instantiate metamodel -->
	<bean id="mm_emf" class="org.eclipse.xtend.typesystem.emf.EmfRegistryMetaModel"/>

	<!-- load model and store it in slot 'model' -->
	<component class="org.eclipse.emf.mwe.utils.Reader">
		<uri value="platform:/resource/${model}" />
		<modelSlot value="model" />
	</component>

	<!-- check model -->
	<component class="org.eclipse.xtend.check.CheckComponent">
		<metaModel idRef="mm_emf"/>
		<checkFile value="metamodel::Checks" />
		<emfAllChildrenSlot value="model" />
	</component>

	<!--  generate code -->
	<component class="org.eclipse.xpand2.Generator">
		<metaModel idRef="mm_emf"/>
		<expand
			value="template::Template::main FOR model" />
		<outlet path="${src-gen}" >
			<postprocessor class="org.eclipse.xpand2.output.JavaBeautifier" />
		</outlet>
	</component>
</workflow>


it should not be a problem to adapt this to other ecore based metamodels.
the workflow expects the metamodel to be already registered to the registry.
if this is not the case with your metamodel you can simply do this by changing to
	<bean class="org.eclipse.emf.mwe.utils.StandaloneSetup" >
		<platformUri value=".."/>
		<registerEcoreFile value="src/metamodel/metamodel.ecore" />
	</bean>




if you have any specific questions feel free to ask.

Regards,
Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: xpand [message #671559 is a reply to message #671295] Wed, 18 May 2011 10:04 Go to previous messageGo to next message
khalil  is currently offline khalil Friend
Messages: 11
Registered: May 2011
Junior Member
hi
thank you, i bégin to configure my workflow, Can you explain me the role of the next line of the workflow please

<expand value="template::Template::main FOR model" />

Regards,
khalil
Re: xpand [message #671560 is a reply to message #671559] Wed, 18 May 2011 10:16 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14664
Registered: July 2009
Senior Member
Hi,

the reader loads the model in to a map (slot) under the key model
the generator does call with the template::Template::main FOR model" statement
the definition main in the file template/Template.xpt for the type of the model roots type e.g.

<<DEFINE main FOR ModelRootsType>>
<<ENDDEFINE>>


~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: xpand [message #671633 is a reply to message #671560] Wed, 18 May 2011 14:26 Go to previous messageGo to next message
khalil  is currently offline khalil Friend
Messages: 11
Registered: May 2011
Junior Member
hi
I followed the template for the workflow configuration and I think I can load the model and meta model but I get an error at running, this is the message
10   INFO  WorkflowRunner     - running workflow: genmodels.oaw
10   INFO  WorkflowRunner     - 
1456 INFO  StandaloneSetup    - Adding dynamic EPackage 'vhdl' from 'src/vhdl.ecore'
1741 INFO  CompositeComponent - XMLReader: Loading XML file vhalams.xmi
22989 INFO  CompositeComponent - Generator: generating 'genmodels::Root FOR model' => src-gen
23197 ERROR AbstractExpressionsUsingWorkflowComponent - Error in Component  of type org.openarchitectureware.xpand2.Generator: 
	EvaluationException : No Definition 'genmodels::Root for type::AnyType' found!
	[23,32] on line 1 'EXPAND genmodels::Root FOR model'

23198 ERROR WorkflowRunner     - Workflow interrupted. Reason: EvaluationException : No Definition 'genmodels::Root for type::AnyType' found!
	[23,32] on line 1 'EXPAND genmodels::Root FOR model'

23199 ERROR WorkflowRunner     - ERROR in Component of type org.openarchitectureware.xpand2.Generator
	No Definition 'genmodels::Root for type::AnyType' found! [EXPAND genmodels::Root FOR model]  in workflow: Generator: generating 'genmodels::Root FOR model' => src-gen


and my workflow
<workflow>
	<property name="plugin-src" value="src"/>

	<bean class="org.eclipse.mwe.emf.StandaloneSetup">
		<registerEcoreFile value="${plugin-src}/vhdl.ecore" />
	</bean>

	<component class="org.openarchitectureware.xsd.XMLReader">
		<modelSlot value="model" />
		<uri value="vhalams.xmi" />
		<metaModel id="mm"
			class="org.openarchitectureware.xsd.XSDMetaModel" />
	</component>
	<component class="org.openarchitectureware.xpand2.Generator">
		<metaModel idRef="mm" />
		<expand value="genmodels::Root FOR model" />
		<outlet path="src-gen" />
	</component>
</workflow>

and the xpandfile
«IMPORT vhdl»

«DEFINE Root FOR vhdl::Model»
«FILE "vhdl.txt"»
Name: «name»

«ENDFILE»
«ENDDEFINE»

if you can fixe this problem i will bé very nice
thanks you for everything
  • Attachment: src.zip
    (Size: 1.17KB, Downloaded 338 times)
Re: xpand [message #671634 is a reply to message #671633] Wed, 18 May 2011 14:27 Go to previous messageGo to next message
khalil  is currently offline khalil Friend
Messages: 11
Registered: May 2011
Junior Member
in the attachement the méta modél and the modél thanks
Re: xpand [message #671709 is a reply to message #671634] Wed, 18 May 2011 18:27 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14664
Registered: July 2009
Senior Member
Hi,

i have no clue why you are using XMLReader which is for reading XSD Based XML files and not for ecore based xmis

what about simply using a workflow as i posted before?

<?xml version="1.0"?>
<workflow>
	<property name="model" value="my.generator.project/src/vhalams.xmi" />
	<property name="src-gen" value="src-gen" />
	
	<!-- set up EMF for standalone execution -->
	<bean class="org.eclipse.mwe.emf.StandaloneSetup" >
		<platformUri value=".."/>
		<registerEcoreFile value="src/metamodel/vhdl.ecore" />
	</bean>

	<!-- load model and store it in slot 'model' -->
	<component class="org.eclipse.mwe.emf.Reader">
		<uri value="platform:/resource/${model}" />
		<modelSlot value="model" />
	</component>

	<!--  generate code -->
	<component class="org.openarchitectureware.xpand2.Generator">
		<metaModel class="org.eclipse.m2t.type.emf.EmfRegistryMetaModel"/>
		<expand
			value="template::Template::main FOR model" />
		<outlet path="${src-gen}" >
			<postprocessor class="org.openarchitectureware.xpand2.output.JavaBeautifier" />
		</outlet>
	</component>
</workflow>



and then i have no idea how you git that xmi,
if i create one with ecore means it would look like

<?xml version="1.0" encoding="ASCII"?>
<Model xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="vhdl" xsi:schemaLocation="vhdl metamodel/vhdl.ecore" name="exemple">
  <entite name="cell">
    <archi name="cell">
      <function name="operation"/>
      <contraints name="x=x+1"/>
      <composants name="microActuator">
        <portInterne name="port1"/>
      </composants>
      <composants name="microSensor">
        <portInterne name="port2"/>
      </composants>
      <composants name="microController">
        <portInterne name="port3"/>
        <portInterne name="port3"/>
      </composants>
      <connector role="port1" port="port3"/>
      <connector role="port2" port="port4"/>
    </archi>
  </entite>
</Model>



~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: xpand [message #671837 is a reply to message #671295] Thu, 19 May 2011 06:54 Go to previous messageGo to next message
khalil  is currently offline khalil Friend
Messages: 11
Registered: May 2011
Junior Member
hi

I used both configuration and I have the same error message for both that follows:

430  INFO  StandaloneSetup    - Registering platform uri 'E:\workspace sysml'
553  INFO  StandaloneSetup    - Adding dynamic EPackage 'vhdl' from 'src/vhdl.ecore'
632  INFO  CompositeComponent - Reader: Loading model from platform:/resource/my.generator.project/src/vhalams.xmi
646  INFO  CompositeComponent - Generator: generating 'template::Template::main FOR Model' => src-gen
681  ERROR AbstractExpressionsUsingWorkflowComponent - Error in Component  of type org.openarchitectureware.xpand2.Generator: 
	EvaluationException : No Definition 'template::Template::main for vhdl::Model' found!
	[23,41] on line 1 'EXPAND template::Template::main FOR Model'

682  ERROR WorkflowRunner     - Workflow interrupted. Reason: EvaluationException : No Definition 'template::Template::main for vhdl::Model' found!
	[23,41] on line 1 'EXPAND template::Template::main FOR Model'

682  ERROR WorkflowRunner     - ERROR in Component of type org.openarchitectureware.xpand2.Generator
	No Definition 'template::Template::main for vhdl::Model' found! [EXPAND template::Template::main FOR Model]  in workflow: Generator: generating 'template::Template::main FOR Model' => src-gen

I think he load the meta model and model but with a problem somewhere
Regards
Re: xpand [message #671840 is a reply to message #671837] Thu, 19 May 2011 07:11 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14664
Registered: July 2009
Senior Member
Hi,

i tried to explain this problem to you before:

guess you have this template in a file src/bla/Blubb.xpt
«IMPORT vhdl»

«DEFINE Root FOR vhdl::Model»
«FILE "vhdl.txt"»
Name: «name»

«ENDFILE»
«ENDDEFINE»


then of course you have to call

<expand
			value="bla::Bliubb::Root FOR model" />


I thought a least the error message from the workflow runner should have given you that hint

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: xpand [message #671937 is a reply to message #671295] Thu, 19 May 2011 11:57 Go to previous messageGo to next message
khalil  is currently offline khalil Friend
Messages: 11
Registered: May 2011
Junior Member
hi
finally it works, now I can start coding, thank you very much for your precious help
Regards
icon8.gif  Re: xpand [message #1760395 is a reply to message #671560] Wed, 26 April 2017 15:16 Go to previous message
gasri mohamed is currently offline gasri mohamedFriend
Messages: 1
Registered: April 2017
Junior Member
hi i need sam help in my workflow and xpand i need to generat metamodel of use case maps in maude strategie if u can help me it will be nice

Previous Topic:Run different templates in Xpand project
Next Topic:Acceleo
Goto Forum:
  


Current Time: Tue Apr 16 07:24:04 GMT 2024

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

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

Back to the top