Package org.docx4j.model.datastorage
Interface CustomXmlDataStorage
- All Known Implementing Classes:
CustomXmlDataStorageImpl
public interface CustomXmlDataStorage
Interface to provide access to the data stored in a
CustomXmlDataStoragePart.
This approach gives the user flexibility as to whether
they use eg JAXB or DOM or dom4j to represent
and manipulate their data.
-
Method Summary
Modifier and TypeMethodDescriptioncachedXPathGetString(String xpath, String prefixMappings) (Unless you are using Saxon as your XPath implementation (XPathFactoryUtil.setxPathFactory)) this uses org.apache.xpath.CachedXPathAPI for better performance, since Apache's old XPathAPI class, have the drawback of instantiating a new XPathContext (and thus building a new DTMManager, and new DTMs) each time it was called.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.factory()Create this object.Write the contents of this object to the org.w3c.dom.DocumentgetXML()Get the XML as a String.voidSet the contents of this object from the input streamvoidsetDocument(Document doc) booleansetNodeValueAtXPath(String xpath, String value, String prefixMappings) voidWrite the contents of this object to the output streamxpathGetNodes(String xpathString, String prefixMappings) xpathGetString(String xpath, String prefixMappings) Get the data pointed to by the xpath.
-
Method Details
-
factory
CustomXmlDataStorage factory()Create this object.- Returns:
-
xpathGetString
Get the data pointed to by the xpath. (return what if it points at a non-existent??)- Parameters:
xpath-- Returns:
- Throws:
Docx4JException
-
cachedXPathGetString
(Unless you are using Saxon as your XPath implementation (XPathFactoryUtil.setxPathFactory)) this uses org.apache.xpath.CachedXPathAPI for better performance, since Apache's old XPathAPI class, have the drawback of instantiating 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. If you are using Saxon, then the cache won't be used.- Parameters:
xpath-prefixMappings-- Returns:
- Throws:
Docx4JException- Since:
- 3.3.1
- See Also:
-
discardCacheXPathObject
void discardCacheXPathObject()Use 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.- Since:
- 3.3.1
-
xpathGetNodes
-
setNodeValueAtXPath
boolean setNodeValueAtXPath(String xpath, String value, String prefixMappings) throws Docx4JException - Throws:
Docx4JException
-
setDocument
Set the contents of this object from the input stream- Parameters:
is-- Throws:
Docx4JException
-
setDocument
- Throws:
Docx4JException
-
writeDocument
Write the contents of this object to the output stream- Parameters:
os-- Throws:
Docx4JException
-
getDocument
Write the contents of this object to the org.w3c.dom.Document- Parameters:
os-- Throws:
Docx4JException
-
getXML
Get the XML as a String.- Throws:
Docx4JException- Since:
- 3.0.1
-