Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: emiliano.davila on September 29, 2021, 05:26:22 am

Title: Problems with Templates and Scripts
Post by: emiliano.davila on September 29, 2021, 05:26:22 am

Hi, we are working with templates and scripts for report generation, but we are getting a problem when trying to get the linked document of an element.

The script is as follows:

(https://i.imgur.com/lzaW40I.png)

And the template is as follows:

(https://i.imgur.com/etSYGvs.png)

The fragment "Template - DER Short DocVinc" refers to the script mentioned above. When generating the report we get the following error:

(https://i.imgur.com/Xtccybp.png)

Any idea how to fix it?
Title: Re: Problems with Templates and Scripts
Post by: philchudley on September 29, 2021, 07:00:57 am
A script driven fragment has to return an XML document, and a linked document is not in XML format.

Not sure why you are using a script, since the element section, once expanded has a linked document section, which when selected will insert the contents of the linked document.

Remove the template fragments.
Expand the element section (the checkboxes)
Select Linked Document (If I remember correctly there are no fields to insert, just the linked document section

Save the template and regenerate.

Phil
Title: Re: Problems with Templates and Scripts
Post by: emiliano.davila on September 29, 2021, 10:25:23 pm
We are using a script because to generate the report we use the elements of a diagram, and these elements do not have more properties to add.

(https://i.imgur.com/u4NuKyZ.png)

We made a script to return the files of the diagram elements, but with the linked documents we have not been able to do it. As I understand, the xml that the template receives has a specific format. Is there any way to transform the linked document into an xml with that format?
Title: Re: Problems with Templates and Scripts
Post by: Geert Bellekens on September 30, 2021, 03:38:03 am
No, it doesn't work that way.

But you can use a Document script template and return the RTF code as is.
See https://sparxsystems.com/enterprise_architect_user_guide/15.2/model_publishing/document_script_fragment.html (https://sparxsystems.com/enterprise_architect_user_guide/15.2/model_publishing/document_script_fragment.html)

Or else use a virtual document to reference each of the used elements individually.

Geert
Title: Re: Problems with Templates and Scripts
Post by: emiliano.davila on September 30, 2021, 10:53:25 pm
Thank you both very much!