I'm using BindingHandler.applyBindings to bind content controls to XML values in custom parts.
Please note that this code predates the Docx4J class (or I would've used Docx4J.bind) and that I'm working with a locally built nigthly version of Docx4j with xalan 2.7.1.
Calling the applyBindings method results in the following failure:
2014-09-15 17:00:31,850 ERROR org.docx4j.XmlUtils: - java.lang.NoSuchMethodException: For extension function, could not find method static org.docx4j.model.datastorage.BindingTraverserXSLT.xpathGenerateRuns([ExpressionContext,] #UNKNOWN (org.docx4j.openpackaging.packages.WordprocessingMLPackage), #UNKNOWN (org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart), #UNKNOWN (java.util.HashMap), #STRING, #NODESET, #STRING, #STRING, #BOOLEAN).
The reason seems to be the 4th parameter, i.e. the following method in BindingTraverserXSLT is not resolved by xalan:
xpathGenerateRuns(WordprocessingMLPackage pkg, JaxbXmlPart sourcePart, Map<String, CustomXmlPart> customXmlDataStorageParts, XPathsPart xPathsPart, NodeIterator sdtPrNodeIt, String sdtParent, String contentChild, boolean multiLine);
As I understand it, as the xPathsPart of my MainDocumentPart is null, XmlUtils' transform() method skips over it when setting its Transformer's parameters.
Xalan's MethodResolver() method, in turn, is passed said parameter as an empty String wrapped by a XString:
[3] = {org.apache.xpath.objects.XString@19672}""
Resulting in the method not being resolved correctly.
This is giving me some grief, and I'm not really sure if the issue is with my usage of Docx4J (same code was OK in 2.8.1) or elsewhere.
Is this the expected behavior?
Edit: also, I think I should mention that I'm binding content controls to several different custom XML parts in the document.
Cheers,
Roded