split /\ / \ a1 a2 \ / \ / join
<?xml version="1.0" encoding="ISO-8859-1"?> <xmi:XMI xmi:version="2.0"> <Split name="s1" followingElement="/1 /2"/> <Class1 name="Action1" followingElement="/3"/> <Class1 name="Action2" followingElement="/3"/> <Join name="j1"> </xmi:XMI>
<?xml version="1.0" encoding="UTF-8"?> <ecore:EPackage xmi:version="2.0" xmlns:xmi="...omg.org/XMI" xmlns:xsi="...w3.org/2001/XMLSchema-instance" xmlns:ecore="...eclipse.org/emf/2002/Ecore" name="Model" nsURI="....example.com/model"> <eClassifiers xsi:type="ecore:EClass" name="Class1" eSuperTypes="#//Class3"/> <eClassifiers xsi:type="ecore:EClass" name="Class2" eSuperTypes="#//Class3"/> <eClassifiers xsi:type="ecore:EClass" name="Class3"> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" lowerBound="1" eType="ecore:EDataType ...eclipse.org/emf/2002/Ecore#//EString"/> <eStructuralFeatures xsi:type="ecore:EReference" name="followingElement_A" upperBound="-1" eType="#//Class1"/> <eStructuralFeatures xsi:type="ecore:EReference" name="followingElement_B" upperBound="-1" eType="#//Class2"/> </eClassifiers> <eClassifiers xsi:type="ecore:EClass" name="Split" eSuperTypes="#//Class2"/> <eClassifiers xsi:type="ecore:EClass" name="Join" eSuperTypes="#//Class2"/> </ecore:EPackage>
«IMPORT Model» «DEFINE main FOR Split» «FILE "testoutput.txt"-» «this.name-» (following: «FOREACH followingElement_A AS e» «e.name» «ENDFOREACH») ------------------------------- «EXPAND def1 FOREACH this.followingElement_A» «ENDFILE» «ENDDEFINE» «DEFINE def1 FOR Model::Class1» «this.name» (following: «FOREACH followingElement_B AS e» «e.name» «ENDFOREACH») ------------------------------- «EXPAND def2 FOREACH this.followingElement_B» «ENDDEFINE» «DEFINE def2 FOR Model::Class2» «this.name» «ENDDEFINE»
<?xml version="1.0" encoding="ISO-8859-1"?> <xmi:XMI xmi:version="2.0"> <Split name="split1" followingElement_A="/1 /2"/> <Class1 name="Action1" followingElement_B="/3"/> <Class1 name="Action2" followingElement_B="/3"/> <Join name="join1"/> </xmi:XMI>
split1 (following: Action1 Action2 ) ------------------------------- Action1 (following: join1 ) ------------------------------- join1 Action2 (following: join1 ) ------------------------------- join1
extension org::eclipse::xtend::util::stdlib::globalvar; String addProcessedElement(Object o) : getGlobalVar("processed") == null ? (storeGlobalVar("processed", {o}) -> "") : (((List)getGlobalVar("processed")).add(o) -> ""); Boolean isProcessedElement(Object o) : getGlobalVar("processed") == null ? false : ((List)getGlobalVar("processed")).contains(o);
«IMPORT metamodel» «EXTENSION template::extensions» «DEFINE main FOR Split» «addProcessedElement(this)» «FILE "testoutput.txt"-» «this.name-» (following: «FOREACH followingElement_A AS e» «e.name» «ENDFOREACH») ------------------------------- «EXPAND def1 FOREACH this.followingElement_A» «ENDFILE» «ENDDEFINE» «DEFINE def1 FOR Class1» «addProcessedElement(this)» «this.name» (following: «FOREACH followingElement_B AS e» «e.name» «ENDFOREACH») ------------------------------- «EXPAND def2 FOREACH this.followingElement_B» «ENDDEFINE» «DEFINE def2 FOR Class2» «IF !isProcessedElement(this)» «addProcessedElement(this)» «this.name» «ENDIF» «ENDDEFINE»