We have been trying a mail merge reading data from an XML file. The word template contains a region that needs to be repeated. How should we define the region in the java code while using IMailMergeDataSource.
Using the XmlMailMerge example project you can perform repeating mail merge using the same code. Simply load the XML data into the XmlMailMergeDataSet class.
Each node in your XML file with child nodes is represented as its own XmlMailMergeDataTable. The XmlMailMergeDataSet class represents all of these tables in one group and it can be passed to the executeWithRegions mail merge method to merge all data including repeating or hierarchical data.
I have attached a template which can be merged using the code below and your data source that you attached. Please let us know if there are any problems.
// Parse the XML data.
DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Due to the nature of XML, you must always have a "root" node, which in your data file at the moment is the LocalTaxCompliant node. If you are expecting to have more than one LocalTaxCompliant, in order for it to be repeated you would have add another node as the root.
The extra wrapper node Properties is not required (however there is no harm in it being there of course). It just means an extra "TableStart\TableEnd" in the template. If you removed the "Properties" node and corresponding TableStart\TableEnd in the template then everything will merge correctly as the multiple "Property" nodes becomes a data table on its own.
If we can help with anything else, please feel free to ask.
XmlMailMergeDataSet - Is this part of Aspose package or a user defined class? Btw, I have been using XmlMailMergeDataTable that implements IMailMergeDataSource. If this is custom class, please provide me a sample.
Thanks for your inquiry. Please find the LocalTaxComplaint.xml file in attachment. Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
Enables storage, such as cookies, related to analytics.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.