TN 019: Configuring XML Report Output Format

Dream Report 5.0 introduced XML as a possible report output format, in addition to PDF, Excel, CSV and Web (HTML5).  With the XML output format, the user first configures a report with all the typical reporting objects – single data objects, expressions, tables, date/time objects, etc.  Report formatting is not critical (colors, alignment, fonts, etc.) as the format does not transfer to the XML output.  Once the content is on the report and the report data output is verified by generating a PDF report, for example, the XML output can be configured:

  1. In Dream Report Studio, double-click on the report name to open the report settings, and select the Report File Format tab:
  2. Check the “XML Format” report target, and then click the associated “Settings” button.
  3. The “XML Report Configuration” dialog window will open with a blank XML document.
  4. At this point, you can either:
    • Create the XML document from scratch by typing in the relevant XML code, and drag available objects from the report into the XML document. This requires basic knowledge of XML formatting; or
    • Import an XML template (by clicking the “Load XML Template” button) to which to add dynamic report content, by dragging available objects from the report.
  5. In the following example, we have loaded a sample XML template into the “GW Monthly Operating Report”. The template already has result data included – for example, <LAB_RESULT_ID>14121B-1B</LAB_RESULT_ID> - so we need to replace the data with dynamic objects from the report.
  6. Simply replace specific text by dragging-and-dropping the appropriate report object from the list of available objects on the left side to the correct location on the XML document:


Tabular Data

Inserting the results of tables into the XML document requires additional steps.  Again, using the above report as an example:

1. Make sure that a Table Name is specified in a table’s configuration (in the table’s “Appearance” settings). If a table is not named, it will not be available to select from the list of report objects on the left side (the same holds true when configuring an Excel output format)

2. Drag and drop the table into the XML wizard - it will be displayed in the wizard, formatted as [tblstep#Blanton##] : (using the Step Table object named “Blanton”, as an example)


 

3. Next, drag-and-drop the listed table column(s) between the symbols ## (as shown above the red arrow). In the wizard, it will be displayed as:

[tblstep#Blanton#Date="[col#1:Date]" Residual="[col#2:Residual]" Flow_Rate="[col#3:Flow_Rate]"#]

4. For the XML output to be readable by an XML reader, use following (bolded) syntax to properly define the table (the first line is always needed in the XML output):

<?xml version="1.0" encoding="UTF-8"?>

<Table name="Blanton">

<HistoryResult name="History">[tblstep#Blanton#<History Date="[col#1:Date]" Residual="[col#2:Residual]" Flow_Rate="[col#3:Flow_Rate]" />#]

</HistoryResult>

</Table>

5. Additional XML code can be added to the XML output wizard, with an additional object from the report.

Testing the XML Report Output

Using the Dream Report Runtime Management Console (RMC) or the Dynamic Report Generator (DRG), select the report, check the “XML” target, and then generate the report:

In the XML output of the above example, notice that the resulting tabular data is inserted into the XML document:

<?xml version="1.0" encoding="UTF-8"?>

<Table name="Blanton">

<HistoryResult name="History">

<History Date="04/01/19 12:00:00 AM" Residual="32.63" Flow_Rate="314" />

<History Date="04/02/19 12:00:00 AM" Residual="40.67" Flow_Rate="277" />

<History Date="04/03/19 12:00:00 AM" Residual="46.04" Flow_Rate="324" />

<History Date="04/04/19 12:00:00 AM" Residual="46.00" Flow_Rate="360" />

...

<History Date="04/27/19 12:00:00 AM" Residual="39.38" Flow_Rate="277" />

<History Date="04/28/19 12:00:00 AM" Residual="33.75" Flow_Rate="365" />

<History Date="04/29/19 12:00:00 AM" Residual="39.42" Flow_Rate="277" />

<History Date="04/30/19 12:00:00 AM" Residual="33.75" Flow_Rate="365" />

</HistoryResult>

</Table>