Accessing XmlDecl in an XML message

The following table provides the correlation names for each XML syntax element in XmlDecl. Use these names to refer to the elements in input messages, and to set elements, attributes, and values in output messages.

Syntax element Correlation name
XmlDecl (XML.XmlDecl)
Version (XML.Version)
Encoding (XML."Encoding")
Standalone (XML.Standalone)

(XML."Encoding") must include quotes, because Encoding is a reserved word.

If you want to refer to the attributes of the XML declaration in an input message, code the following ESQL. These statements are valid for a Compute node, if you are coding for a Database or Filter node, substitute Root for InputRoot.
IF InputRoot.XML.(XML.XmlDecl)* IS NULL THEN
   -- more ESQL --

IF InputRoot.XML.(XML.XmlDecl)*.(XML.Version)* = '1.0' THEN 
   -- more ESQL --

IF InputRoot.XML.(XML.XmlDecl)*.(XML."Encoding")* = 'UTF-8' THEN
   -- more ESQL --

IF InputRoot.XML.(XML.XmlDecl)*.(XML.Standalone)* = 'no' THEN
   -- more ESQL --
If you want to set the XML declaration in an output message in a Compute node, code the following ESQL:
-- Create an XML Declaration
SET OutputRoot.XML.(XML.XmlDecl) = '';

-- Set the Version within the XML Declaration
SET OutputRoot.XML.(XML.XmlDecl).(XML.Version) = '1.0';

-- Set the Encoding within the XML Declaration
SET OutputRoot.XML.(XML.XmlDecl).(XML."Encoding") = 'UTF-8';

-- Set Standalone within the XML Declaration
SET OutputRoot.XML.(XML.XmlDecl).(XML.Standalone) = 'no';  

This ESQL generates the following XML declaration:

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

For further information on the syntax elements involved in the XML declaration, see The XML declaration.

Related concepts
Message flows overview
ESQL overview
Message modeling
Related tasks
Designing a message flow
Defining message flow content
Managing ESQL files
Related reference
Compute node
Database node
Filter node
ESQL reference
IF statement
SET statement