Today is my question day
I have the following UML file and want to generate code out of it:
<?xml version="1.0" encoding="ISO-8859-1"?>
<uml:Model xmi:version="2.1" xmlns:xmi="http://schema.omg.org/spec/XMI/2.1" xmlns:uml="http://schema.omg.org/spec/UML/2.1" xmi:id="themodel" name="UMLTest">
<packagedElement xmi:type="uml:Package" xmi:id="_Y9XL8O2VEd-XTo9qEVpn9A" name="Package">
<packagedElement xmi:type="uml:Class" xmi:id="_bU6SIO2VEd-XTo9qEVpn9A" name="Class"/>
</packagedElement>
</uml:Model>
With the following workflow:
<?xml version="1.0"?>
<workflow>
<!-- Set Properties -->
<property name="model" value="src/model/bouml.uml" />
<property name="dump" value="src/model/test_dump.uml" />
<property name="src-gen" value="src-gen" />
<!-- Set UML environment -->
<bean class="org.eclipse.xtend.typesystem.uml2.Setup" standardUML2Setup="true"/>
<!-- Read in the model -->
<component class="org.eclipse.emf.mwe.utils.Reader">
<modelSlot value="model"/>
<uri value="${model}"/>
</component>
<!-- Write the model -->
<component class="org.eclipse.emf.mwe.utils.Writer">
<modelSlot value="model"/>
<uri value="${dump}"/>
</component>
<!-- Generate code -->
<component id="generator" class="org.eclipse.xpand2.Generator" skipOnErrors="true">
<metaModel class="org.eclipse.xtend.typesystem.uml2.UML2MetaModel"/>
<expand value="templates::Root::Root FOR model"/>
<fileEncoding value="ISO-8859-1"/>
<outlet path="src-gen">
<postprocessor class="org.eclipse.xpand2.output.JavaBeautifier"/>
</outlet>
<resourceManager class ="org.eclipse.xtend.expression.ResourceManagerDefaultImpl">
<fileEncoding value="ISO-8859-1"/>
</resourceManager>
</component>
</workflow>
With the template:
«DEFINE Root FOR uml::Model»
«EXPAND PackageRoot FOREACH allOwnedElements().typeSelect(uml::Package)»
«ENDDEFINE»
«DEFINE PackageRoot FOR uml::Package»
«EXPAND ClassRoot FOREACH ownedType.typeSelect(uml::Class)»
«ENDDEFINE»
«DEFINE ClassRoot FOR uml::Class»
«FILE name+".java"»
public class «name» {}
«ENDFILE»
«ENDDEFINE»
I get these workflow output:
16 INFO WorkflowRunner - running workflow: C:/Programme/Eclipse_Modeling/Workspace/com.bosch.lws.codegen/src/workflow/main.mwe
16 INFO WorkflowRunner -
1360 INFO CompositeComponent - Reader: Loading model from src/model/bouml.uml
3766 INFO CompositeComponent - Writer: Writing model to src/model/test_dump.uml
3844 INFO CompositeComponent - Generator(generator): generating 'templates::Root::Root FOR model' => src-gen
3938 ERROR AbstractExpressionsUsingWorkflowComponent - Error in Component generator of type org.eclipse.xpand2.Generator:
EvaluationException : No Definition 'templates::Root::Root for null::Model' found!
[23,38] on line 1 'EXPAND templates::Root::Root FOR model'
3938 ERROR WorkflowRunner - Workflow interrupted. Reason: No Definition 'templates::Root::Root for null::Model' found!
3938 WARN WorkflowRunner - [WARNING]: the element in slot 'model' is already contained in a resource and will be taken out of that resource!(Element: -UNKNOWN-; Reported by: Writer: Writing model to src/model/test_dump.uml)
3938 ERROR WorkflowRunner - [ERROR]: No Definition 'templates::Root::Root for null::Model' found!(Element: EXPAND templates::Root::Root FOR model; Reported by: Generator(generator): generating 'templates::Root::Root FOR model' => src-gen)
And if I modify the following line
<uml:Model xmi:version="2.1" xmlns:xmi="http://schema.omg.org/spec/XMI/2.1" xmlns:uml="http://schema.omg.org/spec/UML/2.1" xmi:id="themodel" name="UMLTest">
to
<uml:Model xmi:version="2.1" xmlns:xmi="http://schema.omg.org/spec/XMI/2.1" xmlns:uml="http://www.eclipse.org/uml2/3.0.0/UML" xmi:id="themodel" name="UMLTest">
The workflow ends up with no errors. What is the reason for this and how I can change the schema location by code rather than by hand? Maybe I havn't understood the sense behind schema locations yet...
Thanks in advance and bye
Tom
[Updated on: Thu, 11 November 2010 13:45]
Report message to a moderator