Class JaxbCustomXmlDataStoragePart<E>
java.lang.Object
org.docx4j.openpackaging.Base
org.docx4j.openpackaging.parts.Part
org.docx4j.openpackaging.parts.JaxbXmlPart<E>
org.docx4j.openpackaging.parts.opendope.JaxbCustomXmlDataStoragePart<E>
- All Implemented Interfaces:
CustomXmlPart
- Direct Known Subclasses:
BibliographyPart,ComponentsPart,ConditionsPart,DocPropsCoverPagePart,QuestionsPart,StandardisedAnswersPart,XPathsPart
public abstract class JaxbCustomXmlDataStoragePart<E>
extends JaxbXmlPart<E>
implements CustomXmlPart
-
Field Summary
FieldsFields inherited from class org.docx4j.openpackaging.parts.JaxbXmlPart
jaxbElement, jc, log, MAX_BYTES_Unmarshal_ErrorFields inherited from class org.docx4j.openpackaging.Base
contentType, partName, relationships -
Constructor Summary
ConstructorsConstructorDescriptionJaxbCustomXmlDataStoragePart(PartName partName) JaxbCustomXmlDataStoragePart(PartName partName, jakarta.xml.bind.JAXBContext jc) -
Method Summary
Modifier and TypeMethodDescriptioncachedXPathGetString(String xpath, String prefixMappings) Use org.apache.xpath.CachedXPathAPI, since this is much quicker than default javax.xml.xpath.XPath implementations (Apache's anyway) for large XML files.voidUse this to null out the org.apache.xpath.CachedXPathAPI object, which you should do if you've changed your source document, or want to reclaim memory.voidinit()voidXPaths are evaluated against a DOM document representation of the JAXBElement.voidremove()Remove this part from the pkg.booleansetNodeValueAtXPath(String xpath, String value, String prefixMappings) voidSet the XML datavoidxpathGetNodes(String xpathString, String prefixMappings) xpathGetString(String xpathString, String prefixMappings) Methods inherited from class org.docx4j.openpackaging.parts.JaxbXmlPart
addMcChoiceNamespace, getConfiguredUnmarshaller, getContents, getJAXBContext, getJaxbElement, getMcChoiceNamespaces, getMceIgnorable, getXML, inputStreamToXSR, isContentEqual, isUnmarshalled, marshal, marshal, marshal, marshal, pipe, pipe, pipe, preprocess, setContents, setJAXBContext, setJaxbElement, setJaxbElement, setMceIgnorable, transform, transformToDom, unmarshal, unmarshal, variableReplaceMethods inherited from class org.docx4j.openpackaging.parts.Part
getContentLengthAsLoaded, getOwningRelationshipPart, getPackage, getRelationshipType, getSourceRelationship, getSourceRelationships, getVersion, rename, setContentLengthAsLoaded, setOwningRelationshipPart, setPackage, setPartShortcut, setRelationshipType, setSourceRelationship, setVersionMethods inherited from class org.docx4j.openpackaging.Base
addTargetPart, addTargetPart, addTargetPart, addTargetPart, getContentType, getPartName, getRelationshipsPart, getRelationshipsPart, getUserData, reset, setContentType, setPartName, setRelationships, setUserDataMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.docx4j.openpackaging.parts.CustomXmlPart
getXML
-
Field Details
-
doc
This part's XML contents. Not guaranteed to be up to date. Whether it is or not will depend on how the class which extends Part chooses to treat it. It may be that the class uses some other internal representation for its data.
-
-
Constructor Details
-
JaxbCustomXmlDataStoragePart
- Throws:
InvalidFormatException
-
JaxbCustomXmlDataStoragePart
public JaxbCustomXmlDataStoragePart(PartName partName, jakarta.xml.bind.JAXBContext jc) throws InvalidFormatException - Throws:
InvalidFormatException
-
-
Method Details
-
init
public void init() -
readyXPath
public void readyXPath()XPaths are evaluated against a DOM document representation of the JAXBElement. These aren't kept in sync, so you can use this method to update the DOM document from the JAXBElement. -
updateJaxbElementFromDocument
public void updateJaxbElementFromDocument() -
xpathGetString
- Specified by:
xpathGetStringin interfaceCustomXmlPart- Throws:
Docx4JException
-
cachedXPathGetString
Description copied from interface:CustomXmlPartUse org.apache.xpath.CachedXPathAPI, since this is much quicker than default javax.xml.xpath.XPath implementations (Apache's anyway) for large XML files. This is because Apache's old XPathAPI class instantiated a new XPathContext (and thus building a new DTMManager, and new DTMs) each time it was called. XPathAPIObject instead retains its context as long as the object persists, reusing the DTMs. There was the question of whether to declare it here or just implement it in CustomXmlDataStoragePart (since this is mostly of value in binding the user's XML data file). It is here since otherwise BindingHandler would fail on DocPropsCoverPagePart and StandardisedAnswersPart (both of which extend JaxbCustomXmlDataStoragePart).- Specified by:
cachedXPathGetStringin interfaceCustomXmlPart- Returns:
- Throws:
Docx4JException- See Also:
-
discardCacheXPathObject
public void discardCacheXPathObject()Description copied from interface:CustomXmlPartUse this to null out the org.apache.xpath.CachedXPathAPI object, which you should do if you've changed your source document, or want to reclaim memory.- Specified by:
discardCacheXPathObjectin interfaceCustomXmlPart
-
xpathGetNodes
- Specified by:
xpathGetNodesin interfaceCustomXmlPart- Throws:
Docx4JException
-
setNodeValueAtXPath
public boolean setNodeValueAtXPath(String xpath, String value, String prefixMappings) throws Docx4JException - Specified by:
setNodeValueAtXPathin interfaceCustomXmlPart- Throws:
Docx4JException
-
getItemId
- Specified by:
getItemIdin interfaceCustomXmlPart- Since:
- 3.0.2
-
remove
public void remove()Remove this part from the pkg. Beware: it is up to you to make sure your content doesn't rely on this part being present! A symptom of that would be that Office now reports your file to be corrupt or in need of repair. -
setXML
Description copied from interface:CustomXmlPartSet the XML data- Specified by:
setXMLin interfaceCustomXmlPart- Throws:
Docx4JException
-