According to specs it is normal behaviour.
If you replace "self.expandFile1()" by that rule's code you'll have:
texttransformation file_test (in ecore:"ecore") {
ecore.EPackage::main(){
file("file2.txt")
<% write some stuff to file 2!
%>
file("file1.txt")
<% write some stuff to file 1
bla bla bla
%>
<% this should belong to file 2! %>
}
}
In that case, every output between "file("file2.txt")" and
"file("file1.txt")" will go to file2.txt. And every output after
"file("file1.txt")" will go to file1.txt, unless you create another file
or terminate your transformation.
Jan Vandieken a écrit :
Hello
in the MOFScript user guide the behavior of the file statement is described
as follows:
"Output statements (prints and escaped output) will be written to the latest
declared
file in the runtime stack. A file declaration is active as long as the
declaring rule is
active."
I declared two transfomation rules within one texttransformation their
syntax is:
texttransformation file_test (in ecore:"ecore") {
ecore.EPackage::main(){
file("file2.txt")
<% write some stuff to file 2!
%>
self.expandFile1()
<% this should belong to file 2! %>
}
ecore.EPackage::expandFile1(){
file("file1.txt")
<% write some stuff to file 1
bla bla bla
%>
}
}
I would expect two files looking like this:
file1.txt:
write some stuff to file 1
bla bla bla
-----------------------
file2.txt:
write some stuff to file 2!
this should belong to file 2!
-----------------------
But when executing the texttransformation the two files look like this:
file1.txt:
write some stuff to file 1
bla bla bla
this should belong to file 2!
----------------------------------------------
file 2.txt:
write some stuff to file 2!
It seems like the outputstream for the transformation rule expandFile1() is
not closed when the transformation rule is left by the runtime environment.
To me this behavior seems very strange. Does anyone have an explanation for
that?
Regards
Jan