Free Support Forum - aspose.com

"Mustache" mailmerge fields : java.lang.IllegalStateException: Unexpected end of children nodes reached

I am getting the following error, in Aspose.Words 11.8 (jdk 1.4 version):-

java.lang.IllegalStateException: Unexpected end of children nodes reached.
at com.aspose.words.F4.ZWX(Unknown Source)
at com.aspose.words.F4.ZWV(Unknown Source)
at com.aspose.words.F4.Ã(Unknown Source)
at com.aspose.words.MailMerge.Ã(Unknown Source)
at com.aspose.words.MailMerge.executeWithRegions(Unknown Source)
at AsposeWords.mergeXML(ASPOSEWORDS:363)

If required - I can produce a small test case for this tomorrow.
(The Java I am running is in an Oracle Database and processes BLOBs, not files. Therefore - it would need modification for you to run this yourself.).

However, the conditions for the error are:-
1. “Mustache” mail merge fields are used (e.g. {{name}}).
E.g. mm.setUseNonMergeFields(true);
2. Empty paragraphs are set to be removed (either using MailMergeCleanupOptions.REMOVE_EMPTY_PARAGRAPHS or mm.setRemoveEmptyParagraphs(true)).
3. There is a NULL mail merge value on a line by itself (which I would expect to be removed).
4. A custom XML data source is being used. A modified version of this example here.
However, when I put debugging code in there, it shows that the datasource methods are not used, apart from a single call to moveNext().

I wonder if there is some fundamental incompatibility between removing empty paragraphs and “mustache” mailmerge fields? After all, it seems that Mailmerge.getFieldNames() does not list mustache-type mailmerge fields, as demonstarted here.

Additionally, I am finding that the “object.attribute notation” is not working - E.g. {{Address.Street}}.
The example I used was based on the one here. It is simply setting the field to blank. Based on debug messages in the custom XML data source (IMailMergeDataSource) - it is attempting to get the value of “Street” without even attempting to get the “table name” called “Address”.

Thanks.

I’ve attached the test case (a console application) to reproduce these issues.

case 1:
Successful run (without REMOVE_EMPTY_PARAGRAPHS)

java Test N end_of_children.doc end_of_children.xml out.doc

case 2:
unsuccessful run (WITH REMOVE_EMPTY_PARAGRAPHS)

java Test Y end_of_children.doc end_of_children.xml out.doc

case 3:
successful run - but address is missing (Address.Street notation).

java Test N missing_address.doc missing_address.xml out.doc

Hope this helps.
Thanks.

P.S. I forgot to mention that my statement that the field had to be blank to cause the “unexpected of children” exception was wrong. It will happen whether the field is NULL or not (end_of_children.xml does not have any NULL values).

Hi Jonathan,


Thanks for your inquiry.

While using the latest version of Aspose.Words i.e. 11.8.0, I managed to reproduce this exception on my side. I have logged this issue in our bug tracking system. The issue ID is WORDSNET-7129. Your request has been linked to this issue and you will be notified as soon as it is resolved.

Sorry for the inconvenience.

Best Regards,

Hi Jonathan,

Jonathan:
case 3:
successful run - but address is missing (Address.Street notation).
java Test N missing_address.doc missing_address.xml out.doc
I have tested this scenario and have managed to reproduce the same problem on my side. For the sake of correction, I have logged this problem as WORDSNET-7142 in our issue tracking system. We will further look into the details of this problem and will keep you updated on the status of correction. We apologize for your inconvenience.

Best Regards,

The issues you have found earlier (filed as WORDSNET-7142) have been fixed in this .NET update and this Java update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.

The issues you have found earlier (filed as WORDSNET-7129) have been fixed in this .NET update and this Java update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.