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 Details

    • factory

      Create this object.
      Returns:
    • xpathGetString

      String xpathGetString(String xpath, String prefixMappings) throws Docx4JException
      Get the data pointed to by the xpath. (return what if it points at a non-existent??)
      Parameters:
      xpath -
      Returns:
      Throws:
      Docx4JException
    • cachedXPathGetString

      String cachedXPathGetString(String xpath, 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

      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

      List<Node> xpathGetNodes(String xpathString, String prefixMappings)
    • setNodeValueAtXPath

      boolean setNodeValueAtXPath(String xpath, String value, String prefixMappings) throws Docx4JException
      Throws:
      Docx4JException
    • setDocument

      void setDocument(InputStream is) throws Docx4JException
      Set the contents of this object from the input stream
      Parameters:
      is -
      Throws:
      Docx4JException
    • setDocument

      void setDocument(Document doc) throws Docx4JException
      Throws:
      Docx4JException
    • writeDocument

      void writeDocument(OutputStream os) throws Docx4JException
      Write the contents of this object to the output stream
      Parameters:
      os -
      Throws:
      Docx4JException
    • getDocument

      Document getDocument() throws Docx4JException
      Write the contents of this object to the org.w3c.dom.Document
      Parameters:
      os -
      Throws:
      Docx4JException
    • getXML

      String getXML() throws Docx4JException
      Get the XML as a String.
      Throws:
      Docx4JException
      Since:
      3.0.1