Class CustomXmlDataStoragePart

java.lang.Object
org.docx4j.openpackaging.Base
org.docx4j.openpackaging.parts.Part
org.docx4j.openpackaging.parts.CustomXmlDataStoragePart
All Implemented Interfaces:
CustomXmlPart

public final class CustomXmlDataStoragePart
extends Part
implements CustomXmlPart
CustomXmlDataStoragePart contains user custom xml, to which content control bindings can point. This is the modern best practice approach for injecting text/data into a docx. See the Getting Started guide for a general overview, and additional references, or use the docx4j website to search for "custom xml binding". Once you have included this part, and bound content controls to it, nothing further needs to be done for Word to display your data (unless you are using conditional|repeat - see below). However, if you want your data to show up in docx4j PDF|HTML output, you need to run the BindingHandler.applyBindings method first. (TODO: do this automatically) The actual XML data is stored in a CustomXmlDataStorage object, for which accessor is get|setData. (Ths is useful if you want to generate n docx documents, each with different XML.) If this contains XML which is bound in an sdt via w:sdtPr/w:dataBinding, then its rels will point to CustomXmlDataStoragePropertiesPart which gives its datastore itemID. (The datastore itemID is used in the w:dataBinding) The Package contains a hashmap to make it easy to get the part to which we apply the XPath. The part is registered as the document is loaded. This class supports content control extensions (ie od:condition, od:repeat). Use the OpenDoPEHandler class to process these.
Author:
jharrop