I have a template docx with textbox form fields (FldChars of field-type: form-field FORMTEXT).
They store directives how to fill and process template in default text value of ffData elem.
In simple case it needs just to set form field value, in more complicated - delete table or table
raw or paragraph with correnponding form field.
At first i got all FldChars using getJAXBNodesViaXPath(), but i had to for example find parent table
to process it, but i got known jaxb error with JAXBElement instead of parent. So i tried to
get parent Node using binder:
- Code: Select all
List<Object> runList = documentPart.getJAXBNodesViaXPath(xpath, false);
javax.xml.bind.Binder<Node> binder = org.docx4j.jaxb.Context.jc.createBinder();
for (Object o : runList)
{
org.w3c.dom.Node node = binder.getXMLNode(o);
Node parent = node.getParentNode();
...
but node is always NULL.
My questions are:
- What did i wrong with getting xml node from jaxb node?
- Are there any ways to navigate following/preceding siblings of JAXBElements?
- Could you suggest more convenient/right way for doing suth template proccesing task with docx4j?
We have a lot of ready templates with form fields, so i have to use them as thay are.
Thanks.