Skip to main content

Creating XML Output

Processes can be configured to generate XML output instead of the standard spreadsheet-based reports.

Processes can be configured to generate XML output instead of the standard spreadsheet-based reports. An XML output process retrieves data using process inputs, applies an XSL transform to produce the XML, and makes the result available for download from the Process Execution record. The file can also be stored as a named report and attached to an outgoing email.

Setting up XML output involves three steps: creating the process, applying XML-specific configuration, and creating the XSL transform document.


Step 1 — Create the process

In the Configuration application, go to Process Configuration \> Processes and create a new process. Set the Process Type to xml. Instead of uploading a spreadsheet workbook as the Process Logic, upload the XSL transform file. Configure Process Inputs to define the data the transform will operate on — these behave the same as in standard processes. Add Process Outputs and Process Parameters as needed.


Step 2 — XML-specific configuration

Logging level. If the generated XML should be stored in the Calculation Log, set the Logging Level to verbose.

Named report file. If the XML should appear as a downloadable report file in the Process Execution record, create a Process Parameter named XML Report File Name with type String. Set its value to the desired filename. If the parameter is left blank, no report file is created. Only one XML report file can be generated per process execution. If you need multiple XML reports, use a process chain to run multiple XML processes in sequence.

Dynamic filenames. To generate the report filename dynamically at runtime, use a process chain where a standard process determines the filename and passes it to the XML process as a parameter.


Step 3 — Create the XSL transform document

The XSL transform defines the structure of the XML output. Create it using a text editor or XML editor. The document must declare the EnergySys namespace and include a root template:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  version="2.0"
  xmlns:es="http://energysys.com/schema/energysys"
  xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xsl:output method="xml" omit-xml-declaration="yes" indent="yes"/>
  <xsl:template match="/">
    <!-- Your XML structure here -->
  </xsl:template>
</xsl:stylesheet>


Accessing process input data in XSL

Data from process inputs is available via XPath within the transform. The path follows this structure: /es:ProcessData/es:InputData/es:Table, filtered by es:SystemName, then navigating to es:Collection/es:Object and referencing specific es:Attribute positions.

XPath operates on data after the process input filter has been applied. Filter your data using process input filters rather than inside the XSL document — this is more efficient and easier to maintain.


Repeating elements

To produce one XML element per record, use an xsl:for-each loop:

<records>
  <xsl:for-each select="...XPath expression...">
    <record>
      <xsl:value-of select="...attribute reference..."/>
    </record>
  </xsl:for-each>
</records>


Runtime behaviour

When the process runs, inputs retrieve data from the database, the XSL transform generates the XML, and if verbose logging is enabled the XML is stored in the Calculation Log. If a report filename was provided, the file is created and listed in the Process Execution record. If the process is configured to send email, the XML file can be attached as an outgoing attachment. See Sending Email from Processes.

Did this answer your question?