|Re: Errors in XPAND [message #798285 is a reply to message #798269]
||Tue, 14 February 2012 13:43
|| Karsten Thoms
Registered: July 2009
Location: Dortmund, Germany
First, elements from Xtext models will only be referrable when they have a name. By default, your Entity types should have a name attribute like|
Entity1: 'Entity1' name=ID ';'
Otherwise the Reader component would report something like "Could not find any exported element of type Entity1".
The name of elements can be also computed by providing a different IQualifiedNameProvider and bound it to the RuntimeModule, the default implementation will search for the "name" attributes to compute qualified names for elements. Only elements for which the IQualifiedNameProvider returns non-null can be exported into a slot and then passed the Xpand.
The "Collection type expected!" error occurs because there is no multi-valued reference from Entity1 to Entity2 named "Entity2". If you would like to expand each Entity2 from the same model as Entity1, you could go up to the model.
«DEFINE main FOR Entity1»
This is Entity1
«EXPAND test FOREACH ((Model)eContainer).entity2»
Usually this does not really make sense. Usually cross-references would be better here. You should look at the resulting Ecore metamodel from your grammar, this would make it easier to understand your Xpand templates.
Need professional support for Xtext, EMF, Eclipse IDE?
Go to: http://devhub.karakun.com
Twitter : @kthoms
Blog : www.karsten-thoms.de
Powered by FUDForum
. Page generated in 0.03913 seconds