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

Free Support Forum - aspose.com

Mustache Syntax Documentation


I’m new to Aspose.Words for Java and I need to generate a report from an XML file (I started from the MustacheTemplateSyntax example).

The syntax to use foreach tag and to get access to xml nodes is pretty clear, but I also need to use conditionals (IF statements) and use expressions to test if a field in the XML is set or not, if a String field starts with some prefix, …

Is there any online documentation about the tags I can use with Mustache Syntax, how to build expressions, etc?

Joan Mo Torres.

Hi Joan,

Thanks for your inquiry. I suggest you please use ‘LINQ Reporting Engine’ to achieve your requirements. Please read the detail from here:

Following link explains about template syntax.

Regarding conditional blocks, please read following link.

Please use DataSet.readXml method to load the XML in DataSet and perform mail merge operation. Please read following link to work with DataSet data source.

Please check following code example for your kind reference. Hope this helps you. Please let us know if you have any more queries.


<?xml version="1.0" standalone="yes" ?>
DataSet dataSet = new DataSet();
dataSet.readXml(<i>MyDir</i> + "input.xml");
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);    
builder.writeln("<<foreach [s in Student]>>");
ReportingEngine engine = new ReportingEngine();
engine.buildReport(doc, dataSet);    
doc.save(MyDir + "Out.docx");

Thanks a lot for all this information.

I tried to load the DataSet object with the readXml parameter but I can’t find this method…
I’m working on the aspose-words-14.12.0-jdk15.jar, because we are using a very old JBoss version on a java jdk15.

How could I load the xml on the DataSet with this 14.12 version?

Hope to receive good news from you, thanks.


Hi Joan,

Thanks for your inquiry. Unfortunately, this feature (DataSet.readXML) is not available in older version of Aspose.Words. If you want to use this feature, please use latest version of Aspose.Words for Java 15.8.0.

As you are working with XML data source and mustache templates, I suggest you please read following documentation links. Hope this helps you.

Hi Tahir,

We changed our initial idea and we are now trying to load the data to the report engine by using a Java object instead of an xml file using “aspose-words-14.12.0-jdk15.jar”, but it’s failing when running the buildReport method.

The class that we are testing (based on https://docs.aspose.com/words/java/hello-world-example/):

public class LinqEngineTest {
public static void main(String[] args) throws Exception {
String dataDir = "C:/path/to/the/report/";

Document doc = new Document(dataDir + "EscrituraTemplate.doc");
Sender sender = new Sender("LINQ Reporting Engine", "Hello World");
ReportingEngine engine = new ReportingEngine();
engine.buildReport(doc, sender, "s");

doc.save(dataDir + "out.docx");

The exception we are getting:

Exception in thread "main" java.lang.NoClassDefFoundError: [Lorg/objectweb/asm/Type;
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2395)
at java.lang.Class.getDeclaredMethods(Class.java:1763)
at asposewobfuscated.zzWJ.zzY(Unknown Source)
at asposewobfuscated.zzWJ.(Unknown Source)
at asposewobfuscated.zzWK.zzX(Unknown Source)
at asposewobfuscated.zzWH.zzQ(Unknown Source)
at asposewobfuscated.zzWH.zzZ(Unknown Source)
at asposewobfuscated.zzWH.zzY(Unknown Source)
at asposewobfuscated.zzWH.zzZ(Unknown Source)
at asposewobfuscated.zzO7.zzY(Unknown Source)
at asposewobfuscated.zzY5.zzZ(Unknown Source)
at asposewobfuscated.zzY5.zzXw(Unknown Source)
at asposewobfuscated.zzY5.zzXx(Unknown Source)
at asposewobfuscated.zzY5.zzXy(Unknown Source)
at asposewobfuscated.zzY5.zzXz(Unknown Source)
at asposewobfuscated.zzY5.zzXA(Unknown Source)
at asposewobfuscated.zzY5.zzXB(Unknown Source)
at asposewobfuscated.zzY5.zzXC(Unknown Source)
at asposewobfuscated.zzY5.zzXD(Unknown Source)
at asposewobfuscated.zzY5.zzXE(Unknown Source)
at asposewobfuscated.zzY5.zzXF(Unknown Source)
at asposewobfuscated.zzY5.zzXG(Unknown Source)
at asposewobfuscated.zzY5.zzXH(Unknown Source)
at asposewobfuscated.zzY5.zzXI(Unknown Source)
at asposewobfuscated.zzY5.zzXJ(Unknown Source)
at asposewobfuscated.zzY5.zzXM(Unknown Source)
at asposewobfuscated.zzTP.zzZ(Unknown Source)
at asposewobfuscated.zzN7.zzKr(Unknown Source)
at asposewobfuscated.zzX5.zzW4(Unknown Source)
at asposewobfuscated.zzX5.parseTag(Unknown Source)
at asposewobfuscated.zzX5.zzW5(Unknown Source)
at asposewobfuscated.zzN7.zzZ(Unknown Source)
at asposewobfuscated.zzH1.zzZ(Unknown Source)
at asposewobfuscated.zzH1.zzZ(Unknown Source)
at com.aspose.words.ReportingEngine.buildReport(Unknown Source)
at org.notariado.ancert.asposeTest.linq.LinqEngineTest.main(LinqEngineTest.java:17)

I was wondering if that error may be caused by a missing library but I read somewhere that Aspose Words for Java doesn’t have any dependencies…

Do you have any idea?

Thanks for your patience.
Joan Mo Torres.

Hi Joan,

Thanks for your inquiry. After an initial test with latest version of Aspose.Words, I was unable to reproduce this issue on my side. So, please upgrade to the latest version of Aspose.Words for Java i.e. 15.8.0 from here:

Hope, this helps.

Best regards,

A post was split to a new topic: Issue with Mustache “IF” statement