Nested Mail Merge Element Values Empty while Attribute Value Setting at the Same Time | _Text Postfix XML Java

Hi, I use nested Mail Merge for my Word-Document Template, I get all values from the Attribute fields except the Element Field text node values if there is a Attribute value set at the same time.
How can I get the Element node values, even if a Attribute value is set?
Example:
Code.PNG (20.0 KB)
OutputPDF.PNG (12.8 KB)
SourceXML.PNG (5.4 KB)
Template.PNG (6.9 KB)

Best regards

@bennetpe,

Instead of screenshots, it would be great if you please ZIP and attach the following resources here for testing:

  • Your simplified template Word document
  • Aspose.Words for Java 20.8 generated output DOCX file showing the undesired behavior
  • Your expected DOCX file showing the desired output. You can manually create this document by using MS Word.
  • Please also create a standalone simple Java application (source code file without compilation errors) that helps us to reproduce your current problem on our end and attach it here for testing. Please do not include Aspose.Words JAR files in it to reduce the file size.

As soon as you get these pieces of information ready, we will start further investigation into your particular scenario/issue and provide you more information. Thanks for your cooperation.

ExampleProject.zip (107.6 KB)

@bennetpe,

I think, you can either rename the target merge field from “customer” to “customer_Text” (see template - updated.zip (9.9 KB)) or change the last column name in DataSet from “customer_Text” to “customer”. Please see following Java code:

Document doc = new Document("C:\\Temp\\ExampleProject\\template.docx");
DataSet dataSet = new DataSet();
dataSet.readXml("C:\\Temp\\ExampleProject\\data.xml");
System.out.println(dataSet.getTables().get(0).getTableName());
dataSet.getTables().get(0).getColumns().get(2).setColumnName("customer");
doc.getMailMerge().executeWithRegions(dataSet); // execute nested mail merge with regions
doc.save("C:\\temp\\ExampleProject\\awjava-20.8.docx");
1 Like

That worked for me, thank you very much for the support.
Best regards