Prev Next

How to Define a Custom XML Script Fragment

Within a template fragment, you can create a query to report values from an XML file produced by a previously-generated script; for example, the data from a simulation. The query operates on static data that is not updated during generation of the document.

This is an example of the query format:

     Filename=<filepath>\<filename>.xml

     XPath=/EADATA/Dataset_0/Data/Row

The first line is the location of the xml file to process, and the second line is the query to perform on that file, assuming that the file content is:

     <EADATA>

         <Dataset_0>

             <Data>

                 <Row Name="NameValue" Second="Value2"></Row>

                 <Row Name="NameValue2"></Row>

             </Data>

         </Dataset_0>

     </EADATA>

You can then add fields within the 'Custom' section of your Template Fragment, to refer to the data returned by the query. For example, you might edit:

     custom >

     [right-click-to-insert-Custom-field(s)]

     < custom

to give:

     custom >

     Name - Second

     < custom

Creating a Custom XML Script Fragment

Step

Action

See also

1

Using the Scripting window, create a Model Script that returns an XML file.

Scripting

2

Open or create a Template Fragment in the Document Template Editor.

Right-click on the Template background and click on the icon.

The 'Document Options' dialog displays.

Document Templates Creating a Template Fragment

3

Select the 'Custom Query' tab and, in the 'Template Fragment type' panel, select the 'Custom XML' option.

4

In the main text field on the tab, type the entry point of your Script that returns the XML data.  For example:

Filename=<filepath>\<filename>.xml

5

Click on the OK button to close the 'Document Options' dialog.

6

In the Document Template Editor, in the 'Sections' panel, select the 'Custom' checkbox to generate the Custom section.

Setting Sections for Reporting

7

Within the 'Custom' section, right-click and select the 'Insert Custom Field' option.

A prompt displays for the name of the field to create.

8

In response to the prompt, type the name of the data field that is being returned by your script.

Click on the OK button.

9

Repeat steps 7 and 8 for each data field that you want to include in your report.

Add any other formatting and content you need, to the Template Fragment.

10

Save the Template Fragment, and add it to a normal Document Template.

Adding Fragments to a Document Template

Notes

  • The calling statement (not the script that is called) can reference the ID of the element or Package currently being processed by the document template, using the #OBJECTID# or #PACKAGEID# macros; for example, MyRtfData(#OBJECTID#);
         -  #Branch# gets the IDs of the child Packages of the current Package being processed,
            working recursively down to the lowest level of sub-Package; this is only valid when
            processing a Package - elements return a 0 value
         -  #UserName# gets the name of the user logged into version control
         -  #Author# takes the user name from the 'Author' field in the 'General' page of the
            'Preferences' dialog, so the defined search can be performed on objects created
            by that user (this value can be manually re-set in the 'Preferences' dialog)
         -  #Package# gets the package_ID of the currently-selected Package

Learn more