Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Xpand] Merging several models into one output (file) (How can I create one output file contains informations from more than one model?)
[Xpand] Merging several models into one output (file) [message #641842] Sun, 28 November 2010 12:13 Go to previous message
Michael Lindner is currently offline Michael Lindner
Messages: 3
Registered: November 2010
Junior Member
I've got the following DSL written in Xtext:
import "http://www.eclipse.org/xtext/common/JavaVMTypes" as types 

generate mydsl "http://www.test.de/mydsl/MyDsl"

MyModel:
   'mymodel' name=ID '{'
      allSubsystem+=Subsystem*
   '}'
;

Subsystem:
   name=ID '{'
      (messages="messages" '{'
        allMessage+=Message*
      '}')?
   '}'
;

Message:
   'error' name=ID (allLanguage+=MessageLang (','? allLanguage+=MessageLang)* )
;

MessageLang:
    lang=MessageLanguage '=>' message=STRING
;

enum MessageLanguage:   DE | EN;


My default workflow looks like this:
Workflow {
  component = org.eclipse.xtext.mwe.Reader {
    // lookup all resources on the classpath
    useJavaClassPath = true

    // or define search scope explicitly
    path = modelPath

    // this class will be generated by the xtext generator 
    register = de.db.kolt.ribdsl.RibDslStandaloneSetup {}
    load = {
      slot = "allMyModel"
      type = "MyModel"
    }
  }

  component = org.eclipse.xpand2.Generator {
    expand = "templates::Main::processMain FOREACH allMyModel"
    outlet = {
      path = targetDir
    }
    fileEncoding = fileEncoding
  }
}


Not really spectacular. But now my question. If I run the workflow and my Xpand file looks like this
«DEFINE processMain FOR MyModel-»
  «EXPAND processMessage»
«ENDDEFINE»

«DEFINE processMessage FOR MyModel»
  «FILE "messages.properties"»
    «FOREACH allSubsystem.allMessage AS message»
      «FOREACH message.allLanguage AS entry»
        «REM»the entry is unique by the name of the subsystem + "." + name of the mesage«ENDREM»
        «((Subsystem)message.eContainer()).name».«message.name»=«entry.message»
       «ENDFOREACH»
    «ENDFOREACH»
  «ENDFILE»
«ENDDEFINE»


the generator only produces one output file with the first model of one file. But I have more than one file in my source-directory. In every file (model) are several messages.

Who can I create only one output file ("messages.properties") which contains all messages from all models out of many files?

Than you

Michael
 
Read Message
Read Message
Read Message
Previous Topic:[Xpand / Xtend] Recognizing custom UML Profile
Next Topic:[Xpand / Xtend] typeSelect() on stereotype does not work
Goto Forum:
  


Current Time: Sun May 19 23:29:42 EDT 2013

Powered by FUDForum. Page generated in 0.01681 seconds