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

Free Support Forum - aspose.com

The same table (item) cannot be the child table in two nested relations

I am trying to use mail merge to output a letter from XML data. The letter has sender and recipient entities, both sender and recipient contain a “contact” entity that has a “name”.

When I submit the request I get the following error message:

400 Client Error: Bad Request

{“Message”:“The same table ‘contact’ cannot be the child table in two nested relations.”}

I have attached the .DOCX file as well as the .XML file that I’m sending along with the request.

Hi there,

Thanks for your inquiry. In your case, I suggest you please do not use . (dot) in mail merge field and pass the data source accordingly.

Could you please share if you are using executeMailMerge with withRegions parameter?

Thanks for your response!

Just to try to narrow down the problem, I removed all the merge fields from the .docx file and tried again, but the error persists. I think this means that the problem is that the API is unable to deal with the XML content (as attached in the first message).

So perhaps the question is, if I have valid XML content that may have similarly nested structures in different elements, how do I restructure that XML so that the API will accept it? Or, is there a bug in the API that causes it to reject these data structures?


In case it helps, attached to this message is:

1 - a single Python program which sends the XML and the blank document and gets the failing response. NB - The forum prevents me from uploading a test_merge.py file, so I renamed it test_merge.py.txt

2 - A file BlankDocument.docx which doesn’t contain any merge fields at all.

Without any merge fields in the document at all, this program fails with the message;

400 Client Error: Bad Request

{“Message”:“The same table ‘contact’ cannot be the child table in two nested relations.”}

I think I haven’t answered your question yet - yes I am using withRegions parameter in executeMailMerge.

Attached is an example that actually works and merges data into the fields. To create this example from the prior, I removed the nested structures in the XML, and simplified the merge field addressing from the first .docx file.

Unfortunately, this data is not as complex as I need it to be. In this example, the and elements don’t have any nested elements / attributes. But my real data does have nested elements / attributes. So I think my question is, how do I represent these more complex structures in the XML?

Hi there,

Thanks for sharing the detail. I have modified your input document and XML. Please try the mail merge with regions using attached documents and let us know if you still face any issue.


Thank you. It looks like you updated the XML to have an additional root element.

I tried this but I am still getting the same error. I’ve attached a zip file called support_example.zip which has in it a program test_merge.py. If you first set the environment variables for ‘ASPOSE_APP_KEY’ and ‘ASPOSE_APP_SID’ it will replicate exactly the error I am getting.

thank you,


Hi Erik,

Thanks for sharing the
detail. Please check my colleague’s reply from [here](https://forum.aspose.com/t/49666) about your query. Hope this helps you.

Thanks for your response. It does help me to populate this sample document.

But I already could do that (per the example I provided a few messages back).

What I really need is either:

  • A process / algorithm / method to convert my relational data into XML that the Cloud API will accept, or
  • A schema or some other documentation on what sorts of XML data structures are permitted, so that I can build that conversion algorithm myself.
Does this make sense? Said differently, I have data in tables, some of those tables have foreign keys or reverse foreign keys to other tables, and so on. What are the rules I need to follow to translate this sort of arbitrarily nested data to XML in an automatic and predictable way so that I know my templates will work?


Please follow your latest thread on this topic at https://forum.aspose.com/t/49666.

Best Regards,