How to use IF ELSE statement in LINQ Reporting template using Java

Need some advice on a conditional IF Statement in Word.
I have written the below code and its throwing error.
Requesting you please help on correcting the below statement please

eg:<<if << [variables.get(“city”)]>> ==”null” >>“NO” <> <<[variables.get(“city”)]>>


Please use the following template syntax to avoid the exception. Hope this helps you.

<<if [variables.get("city") =="null"]>>"NO" <<else>> <<[variables.get(“city”)]>>

If you still face problem, please ZIP and attach your input Word document and code example here for testing. We will investigate the issue and provide you more information on it.


I tried the below and getting the error
java.lang.IllegalStateException: Tag ‘if’ is not well-formed. Character ‘=’ is unexpected.

I also tried with the below one and got the UNKNOWN VALUE displayed.

I am using the alfresco activiti to display the document.Alfresco activiti using aspose to display the dynamic values. The city value will come as null (String data type). so that why i am in need of condition to write if the city value is null then display as NO.else display the city name.
Please find the attached document for (14.7 KB)


Please also share the simplified code example to reproduce this issue at our end. Thanks for your cooperation.


We noticed that the IF syntax is wrong in your input document. Please check the following syntax.

<<if [variables.get("city") =="null"]>>"NO" <<else>> <<[variables.get(“city”)]>>

We have created the .NET and Java template documents and code examples for your kind reference. Please check the attached documents and following code example. Hope this helps you. (30.1 KB)

Java Code:

Document doc = new Document(MyDir + "inputDotJava.docx");
DataTable dt = new DataTable("variables");
DataRow row = dt.newRow();
row.set("city", "City Name");

ReportingEngine engine = new ReportingEngine();
engine.buildReport(doc, dt.getRows().get(0), "variables"); + "out.docx");

C# Code

Document doc = new Document(MyDir + "inputDotNet.docx");

DataTable dt = new DataTable("variables");
dt.Columns.Add("city", typeof(string));
dt.Rows.Add(new object[] { null });

ReportingEngine engine = new ReportingEngine();
engine.BuildReport(doc, dt.Rows[0], "variables");
doc.Save(MyDir + "out.docx");