|
|
|
|
|
Re: [XPAND] Generating More Than One Instance [message #809033 is a reply to message #808975] |
Tue, 28 February 2012 12:18   |
|
Hi,
you call your workflow for inputs
=> it will be called foreach input
you have the file within the foreachs (the partial template you posted indicates that)
=>
you will call the file foreach output
=> it will not work
you have as i said (3) options
(1) restructure the templates to take a main (root of your dsl) as generation root
(you might have to trick cause it does not have a name - but the solution for that is described 1000 times in the forum - you wíll see if you google for the errror message)
(2) restructure the template (but beeing inefficient)
«IMPORT org::xtext::example::mydsl2::myDsl»
«EXTENSION templates::Extensions»
«DEFINE main FOR Input»
«FILE name+".txt"»
«FOREACH ((main)eContainer()).input AS in»
«in.name»
«ENDFOREACH»
«FOREACH ((main)eContainer()).output AS out»
«out.name»
«ENDFOREACH»
«ENDFILE-»
«ENDDEFINE»
(3) or you configure the outlet with append=true in the workflow
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
|
Re: [XPAND] Generating More Than One Instance [message #810918 is a reply to message #810551] |
Thu, 01 March 2012 17:28   |
|
Hi,
it is quite easy
(1) if you change the template to
«DEFINE main FOR main-»
«FILE "test.txt"-»
«FOREACH input AS i»
«i.name»
«ENDFOREACH»
«FOREACH output AS o»
«o.name»
«ENDFOREACH»
«ENDFILE-»
«ENDDEFINE»
and the workflow to
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 = org.xtext.example.mydsl1.MyDslStandaloneSetup {}
load = {
slot = "main"
type = "main"
}
}
component = org.eclipse.xpand2.Generator {
expand = "templates::Template::main FOREACH main"
outlet = {
path = targetDir
}
fileEncoding = fileEncoding
}
}
you will get the error message
0 [main] DEBUG org.eclipse.xtext.mwe.Reader - Resource Pathes : [src/model]
0 [main] INFO org.eclipse.xpand2.Generator - No meta models configured, using JavaBeans as default.
141 [main] DEBUG xt.validation.ResourceValidatorImpl - Syntax check OK! Resource: file:/C:/work/xtext/Xtext102/ws_xxxxx/org.xtext.example.mydsl1.generator/src/model/Example.mydsl1
219 [main] WARN org.eclipse.xtext.mwe.SlotEntry - Could not find any exported element of type 'main' -> Slot 'main' is empty.
251 [main] INFO .emf.mwe2.runtime.workflow.Workflow - Done.
you can work arround this (this is the place where i asked you to google)
e.g. using a IQualifiedNameProvider that gives the main a name
btw you should have go this error message anyway. at least with the workflow you posted
(2) since you example is very very simple and you did not say anything regarding your problem i still do not understand why you cannot do something like
«IMPORT org::xtext::example::mydsl2::myDsl»
«EXTENSION templates::Extensions»
«DEFINE main FOR Input»
«FILE name+".txt"»
«FOREACH ((main)eContainer()).input AS in»
«in.name»
«ENDFOREACH»
«FOREACH ((main)eContainer()).output AS out»
«out.name»
«ENDFOREACH»
«FOREACH ((main)eContainer()).input AS in»
«in.name»
«ENDFOREACH»
«FOREACH ((main)eContainer()).output AS out»
«out.name»
«ENDFOREACH»
«FOREACH ((main)eContainer()).input AS in»
«in.name»
«ENDFOREACH»
«FOREACH ((main)eContainer()).output AS out»
«out.name»
«ENDFOREACH»
«ENDFILE-»
«ENDDEFINE»
(3)
what about simple
component = org.eclipse.xpand2.Generator {
expand = "templates::Template::main FOREACH main"
outlet = {
path = targetDir
append = true
}
fileEncoding = fileEncoding
}
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
[Updated on: Thu, 01 March 2012 17:29] Report message to a moderator
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02341 seconds