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

Free Support Forum - aspose.com

Probleme with XmlMailMergeDataTable

Hello,

I have a probleme trying to execute the xml mail merge data table as indicated in http://www.aspose.com/docs/display/wordsjava/How+to++Mail+Merge+from+XML+using+IMailMergeDataSource

When I execute de mail merge I get this exception :

Caused by: java.lang.RuntimeException: java.lang.RuntimeException: javax.xml.xpath.XPathExpressionException: javax.xml.transform.TransformerException: Expression vide.
at com.aspose.words.zz3C.zzj(Unknown Source)
at com.aspose.words.zz3C.zzu(Unknown Source)
at com.aspose.words.zz26.zzs(Unknown Source)
at com.aspose.words.zz26.zzt(Unknown Source)
at com.aspose.words.zzZMG.zzZ(Unknown Source)
at com.aspose.words.zzZMG.zzZz3(Unknown Source)
at com.aspose.words.zzZMG.zzZ(Unknown Source)
at com.aspose.words.MailMerge.zzZ(Unknown Source)
at com.aspose.words.MailMerge.execute(Unknown Source)
at com.pocaspose.publipostage.service.GenerationDocumentService.genererDocument(GenerationDocumentService.java:145)
… 26 more
Caused by: java.lang.RuntimeException: javax.xml.xpath.XPathExpressionException: javax.xml.transform.TransformerException: Expression vide.
at com.aspose.words.zzZJ7.zzVC(Unknown Source)
at com.aspose.words.zz3P.zzX6(Unknown Source)
at com.aspose.words.zz3Y.zzZ(Unknown Source)
at com.aspose.words.zz3Y.zzZTX(Unknown Source)
at com.aspose.words.zz3Y.(Unknown Source)
at com.aspose.words.Field.zzZUE(Unknown Source)
at com.aspose.words.Field.zzZ(Unknown Source)
at com.aspose.words.zz2C.zzZ(Unknown Source)
at com.aspose.words.zz2C.zzZ(Unknown Source)
at com.aspose.words.zz26.zzG(Unknown Source)
at com.aspose.words.zz26.zzZ(Unknown Source)
at com.aspose.words.zz26$zzZ.zzZSW(Unknown Source)
at com.aspose.words.zz3C.visitFieldEnd(Unknown Source)
at com.aspose.words.FieldEnd.accept(Unknown Source)
at com.aspose.words.CompositeNode.acceptChildren(Unknown Source)
at com.aspose.words.CompositeNode.acceptCore(Unknown Source)
at com.aspose.words.Paragraph.accept(Unknown Source)
at com.aspose.words.CompositeNode.acceptChildren(Unknown Source)
at com.aspose.words.CompositeNode.acceptCore(Unknown Source)
at com.aspose.words.Body.accept(Unknown Source)
at com.aspose.words.CompositeNode.acceptChildren(Unknown Source)
at com.aspose.words.CompositeNode.acceptCore(Unknown Source)
at com.aspose.words.Section.accept(Unknown Source)
at com.aspose.words.zz3C.zzj(Unknown Source)
… 35 more

this xml file is in the attache.

Tanks for your Help

Hello,

I fixed the probleme by adding :

    /**
* Aspose.Words calls this method to get a value for every data field.
*/
public boolean getValue(String fieldName, Object[] fieldValue) throws Exception
{
if (StringUtils.isBlank(fieldName)) {
return false;
}

        // Attempt to retrieve the child node matching the field name by using XPath.
Node value = (Node)retrieveExpression(fieldName).evaluate(mCurrentNode, XPathConstants.NODE);
// We also look for the field name in attributes of the element node.
Element nodeAsElement = (Element)mCurrentNode;
    <span class="code-keyword" style="color: rgb(0, 0, 145); background-color: inherit;">if</span> (value != <span class="code-keyword" style="color: rgb(0, 0, 145); background-color: inherit;">null</span>)
    {
        <span class="code-comment" style="color: rgb(128, 128, 128); background-color: inherit;">// Field exists in the data source as a child node, pass the value and <span class="code-keyword" style="color: rgb(0, 0, 145); background-color: inherit;">return</span> <span class="code-keyword" style="color: rgb(0, 0, 145); background-color: inherit;">true</span>.

// This merges the data into the document.
fieldValue[0] = value.getTextContent();
return true;
}
else if (nodeAsElement.hasAttribute(fieldName))
{
// Field exists in the data source as an attribute of the current node,
// pass the value and return true.
// This merges the data into the document.
fieldValue[0] = nodeAsElement.getAttribute(fieldName);
return true;
}
else
{
// Field does not exist in the data source, return false.
// No value will be merged for this field and it is left over in
// the document.
return false;
}
}

Hope that will not cause a regression :smiley:


Hi there,

Thanks for your inquiry. It is nice to hear from you that you have solved your issue. Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.