[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.technology.gmt] Re: MOFScript: Streamoutput written to wrong file

For me it is not a behavior described in the spec. As I wrote below the MOFScript User Guide says that an outputstream is active as long as the declaring rule is active.

In my example there are two rules. The first one declaring outputstream to file2.txt and the second one declaring outputstream to file1.txt. But after the second transformation rule returned (is taken from the execution stack) the outputstream is still set to file1.txt.

Well to me this behavior seems to come along with version 1.1.5. After downgrading the MOFScript environment to 1.1.4 the output was written as I expected.


Yannick wrote:
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