m2doc

Why is the interpreter view checking both genconf and template files?


we are using M2Doc programmatically within our Eclipse application and would like to enable the M2Doc interpreter view for our users.

In our normal document generation, we do not generate a .genconf file, and we do not insert variable information as extended properties into the .docx template file.

When we now tried to create a .genconf file for usage with the interpreter view, we realized that apparently not only the .genconf file is necessary, but also the variable information as extended properties within the .docx template file. If variable is defined in only one place, the variable is somehow recognized by the interpreter (no error), but the value is "null".

So my primary questions:

  1. Why is the interpreter view looking into the .docx template at all (especially the extended variable properties), why isn't the .genconf file information about the variables enough (plus the connection to the EMF model)?
  2. Could the interpreter view access be simplified to work already just with the .genconf file?

One related question: 3) Is it possible to programmatically load the .genconf file into the interpreter view (after its creation)? So that the user does not have to manually find the .genconf file somewhere in a directory?

Thanks!

Best Regards, Nils


Solution

    1. The interpreter rely on the genconf to be in the same context as a generation. It allows to provide sample value for each variable that can be then used in the interpreter. The interperter also parse the template to get all declared variable (in for or let for instance) and set them to sample value.

    2. You could probably provide your own view and override M2DocInterpreterView.setGenconfURI(URI) to prevent calls to parseVariableTypes() and parseVariableValues(). Instead add your own computed variables type and value.

    3. M2DocInterpreterView.setGenconfURI(URI) will update the context of the interpreter view.