Class 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 Details

    • doc

      protected Document 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

  • 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

      public String xpathGetString(String xpathString, String prefixMappings) throws Docx4JException
      Specified by:
      xpathGetString in interface CustomXmlPart
      Throws:
      Docx4JException
    • cachedXPathGetString

      public String cachedXPathGetString(String xpath, String prefixMappings) throws Docx4JException
      Description copied from interface: CustomXmlPart
      Use 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:
      cachedXPathGetString in interface CustomXmlPart
      Returns:
      Throws:
      Docx4JException
      See Also:
    • discardCacheXPathObject

      public void discardCacheXPathObject()
      Description copied from interface: CustomXmlPart
      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.
      Specified by:
      discardCacheXPathObject in interface CustomXmlPart
    • xpathGetNodes

      public List<Node> xpathGetNodes(String xpathString, String prefixMappings) throws Docx4JException
      Specified by:
      xpathGetNodes in interface CustomXmlPart
      Throws:
      Docx4JException
    • setNodeValueAtXPath

      public boolean setNodeValueAtXPath(String xpath, String value, String prefixMappings) throws Docx4JException
      Specified by:
      setNodeValueAtXPath in interface CustomXmlPart
      Throws:
      Docx4JException
    • getItemId

      public String getItemId()
      Specified by:
      getItemId in interface CustomXmlPart
      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.
      Overrides:
      remove in class Part
      Since:
      3.0.2
    • setXML

      public void setXML(Document xmlDocument) throws Docx4JException
      Description copied from interface: CustomXmlPart
      Set the XML data
      Specified by:
      setXML in interface CustomXmlPart
      Throws:
      Docx4JException