We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

LINQ Reporting Engine template syntax and behaviour


I have Aspose Word template which I’m populating using XML-file. However, values in the XML might be empty or null. I have reporting engine option allowmissingmembers enabled. My problem is, that when certain nodes are completely empty in the XML-file (meaning that it has no values anywhere within incoming XML-file), my if-logic within template stops working. Currently I’m checking if the node contains values this way

<<if[additionalservices!=null || additionalservices.Any()]>> -> Do stuff

That works if any of the additionalservices-nodes actually contain anything. However, if ALL of them are empty, then following error comes up. It seems like it behaves very differently if no values are present at all.

Tag ‘if’ is not well-formed. A conditional expression should return a Boolean value.

I have attached working and not working xml-samples to this message. Please check the additionalservices-node.

Thank you!


It seems like you use an older version of Aspose.Words. Could you please check the behavior using Aspose.Words 22.11 or later and let us know if the issue is still present?


Updating Aspose.Words to latest version fixed that issue. However, I am now facing another one :smile:

Our incoming XML-nodes can be empty. We have enabled AllowMissingMembers-engine option. In my template, I need to check if node contains anything. If it does not, I want to print text “Empty” or nothing at all. If node contains something, I want to print text “contains following values”. The node in question is the additionalservices node. You can see examples in the attached XML-files. What is the Words Template syntax to check this? I have tried the following:

<<if[additionalservices.Any()]>>contains following values<<else>>Empty<</if>>

This does work, if every node is empty. However, if one node contains values and another one does not, it will print “contains following values” to every row even if the node is empty.

I have also tried this:

<<if[additionalservices!=null]>>contains following values<<else>>Empty<</if>>

This does not work either, it will act like the node contains something.

Thank you!


I am afraid, I cannot find the mentioned files. Could you please share them along with a template document as it seems that you use if in conjunction with foreach. This would help us to better understand your scenario.


Sorry, forgot to actually add the files. They are now attached to this message. The problematic nodes in the XML’s are the additionalservices-nodes. And I have highlighted the problem within template with yellow marker.

xmlsandtemplate.zip (59.0 KB)



To get expected results, you should apply Any() within if to the same collection you use within dependant foreach. I have modified your template to show this. Please check test_modified.docx (58.3 KB).

As a note, it is not necessary to wrap a table-row data band with a table-row conditional block just to ensure that there are some items to output, the data band alone handles this scenario. The modified template was also simplified accordingly.


Yet another note: I had to add <<var [xml=data]>> to the modified template to make it work with the shared XML files, so maybe it is needed to remove the tag before using the template in your original environment.