serializeDataElementsToXML

The serializeDataElements class is used to serialize XML data by setting values of all DDEs, PH, and Field elements. The Generate a Letter PDF API consumes this serialized XML to render the letter. This process appends PH and Field data (provided as maps) to the DDI (provided as XML). You can use this API to provide variable and field values before rendering the letter. The values of DDEs are described in this table:

DDE

Description

ddiDataAsXml

The DDI data as XML.

phValues

A map containing the variable name versus its value.

fieldValues

A map containing the somExpr of Field versus the value of the Field.

The serializeDataElements syntax is as follows:
public String serializeDataElementsToXML(String ddiDataAsXml,Map<String,Object> phValues,Map<String,Object> fieldValues)

The XML data given to LetterRenderService.renderLetter() APIs data has additional elements in following format, where values of place holder variables and fields is provided.

<data-root> 
... 
   <fields>  <!--starting element for fields --> 
      <field name="field1">value1</field> <!-- field's display-name is field1 and its value is set to value1. --> 
      <field name="field2" somExpr="xfa[0].template[0].field2">value2</field> <!-- Attribute somexpr is optional and can be used when display name is not sufficient to identify field uniquely --> 
      ... 
   </fields> 
 
   <variables> <!--starting element for place holder variables--> 
         <variable name="var1">value1</variable> <!-- variable name is var1 and its value is set to value1 --> 
         ....  
    </variables> 
</data-root>

The DDEs values are provided as part of XML data. The renderLetter() considers values provided with XML data and if there is value available for corresponding DDE/PH/Field then these values is set for these DDE/PH/Field. All other values are resolved through Binding. The field/variable binding is not considered if XML data is available for variables or fields. For example, if a Field is bound to an unprotected data dictionary, and the value for the Field is specified in the XML data, then specified value is used for rendering. When no value is set in the XML data,the values of variables/Fields are set using bindings (if present) and empty in case of binding a "User". For example, if a Variable is bound to unprotected data dictionary, and no value specified in the XML data, the data dictionary value is used when rendering letter.

// Ethnio survey code removed