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 Type Method Description java.lang.StringcachedXPathGetString(java.lang.String xpath, java.lang.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.voiddiscardCacheXPathObject()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.CustomXmlDataStoragefactory()Create this object.org.w3c.dom.DocumentgetDocument()Write the contents of this object to the org.w3c.dom.Documentjava.lang.StringgetXML()Get the XML as a String.voidsetDocument(java.io.InputStream is)Set the contents of this object from the input streamvoidsetDocument(org.w3c.dom.Document doc)booleansetNodeValueAtXPath(java.lang.String xpath, java.lang.String value, java.lang.String prefixMappings)voidwriteDocument(java.io.OutputStream os)Write the contents of this object to the output streamjava.util.List<org.w3c.dom.Node>xpathGetNodes(java.lang.String xpathString, java.lang.String prefixMappings)java.lang.StringxpathGetString(java.lang.String xpath, java.lang.String prefixMappings)Get the data pointed to by the xpath.
-
Method Details
-
factory
CustomXmlDataStorage factory()Create this object.- Returns:
-
xpathGetString
java.lang.String xpathGetString(java.lang.String xpath, java.lang.String prefixMappings) throws Docx4JExceptionGet the data pointed to by the xpath. (return what if it points at a non-existent??)- Parameters:
xpath-- Returns:
- Throws:
Docx4JException
-
cachedXPathGetString
java.lang.String cachedXPathGetString(java.lang.String xpath, java.lang.String prefixMappings) throws Docx4JException(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()
-
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
java.util.List<org.w3c.dom.Node> xpathGetNodes(java.lang.String xpathString, java.lang.String prefixMappings) -
setNodeValueAtXPath
boolean setNodeValueAtXPath(java.lang.String xpath, java.lang.String value, java.lang.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
-