Package org.docx4j.openpackaging.parts
Interface XPathEnabled<E>
- All Known Implementing Classes:
CalcChain,Chart,ChartShapePart,ChartsheetPart,CommentAuthorsPart,CommentsPart,CommentsPart,CommentsPart,ConnectionsPart,DiagramColorsPart,DiagramDataPart,DiagramDrawingPart,DiagramLayoutHeaderPart,DiagramLayoutPart,DiagramStylePart,DocumentPart,DocumentSettingsPart,Drawing,EndnotesPart,ExternalLinkPart,FooterPart,FootnotesPart,GlossaryDocumentPart,HandoutMasterPart,HeaderPart,JaxbDmlPart,JaxbPmlPart,JaxbSmlPart,JaxbXmlPartAltChunkHost,JaxbXmlPartXPathAware,MainDocumentPart,MainPresentationPart,NotesMasterPart,NotesSlidePart,NumberingDefinitionsPart,PivotCacheDefinition,PivotCacheRecords,PivotTable,PresentationPropertiesPart,QueryTablePart,SharedStrings,SlideLayoutPart,SlideMasterPart,SlidePart,StyleDefinitionsPart,Styles,TablePart,TagsPart,ThemeOverridePart,ThemePart,ViewPropertiesPart,VMLPart,WorkbookPart,WorksheetPart
public interface XPathEnabled<E>
-
Method Summary
Modifier and Type Method Description EcreateBinderAndJaxbElement(E source)Set the JAXBElement for this part, and a corresponding binder, based on the object provided.javax.xml.bind.Binder<org.w3c.dom.Node>getBinder()Enables synchronization between XML infoset nodes and JAXB objects representing same XML document.java.util.List<JAXBAssociation>getJAXBAssociationsForXPath(java.lang.Object someJaxbElement, java.lang.String xpathExpr, boolean refreshXmlFirst)Fetch DOM node / JAXB object pairs matching an XPath (for example ".//w:p" - note the dot, which is necessary for this sort of relative path).java.util.List<JAXBAssociation>getJAXBAssociationsForXPath(java.lang.String xpathExpr, boolean refreshXmlFirst)Fetch DOM node / JAXB object pairs matching an XPath (for example "//w:p").java.util.List<java.lang.Object>getJAXBNodesViaXPath(java.lang.String xpathExpr, boolean refreshXmlFirst)Fetch JAXB Nodes matching an XPath (for example "//w:p").java.util.List<java.lang.Object>getJAXBNodesViaXPath(java.lang.String xpathExpr, java.lang.Object someJaxbElement, boolean refreshXmlFirst)Fetch JAXB Nodes matching an XPath (for example ".//w:p" - note the dot, which is necessary for this sort of relative path).
-
Method Details
-
getBinder
javax.xml.bind.Binder<org.w3c.dom.Node> getBinder()Enables synchronization between XML infoset nodes and JAXB objects representing same XML document. An instance of this class maintains the association between XML nodes of an infoset preserving view and a JAXB representation of an XML document. Navigation between the two views is provided by the methods getXMLNode(Object) and getJAXBNode(Object) . In theory, modifications can be made to either the infoset preserving view or the JAXB representation of the document while the other view remains unmodified. The binder ought to be able to synchronize the changes made in the modified view back into the other view using the appropriate Binder update methods, #updateXML(Object, Object) or #updateJAXB(Object). But JAXB doesn't currently work as advertised .. access to this object is offered for advanced users on an experimental basis only. -
createBinderAndJaxbElement
Set the JAXBElement for this part, and a corresponding binder, based on the object provided. Returns the new JAXBElement, so calling code can manipulate it. Beware that this object is different to the one passed in!- Parameters:
source-- Returns:
- Throws:
javax.xml.bind.JAXBException- Since:
- 3.0.0
-
getJAXBNodesViaXPath
java.util.List<java.lang.Object> getJAXBNodesViaXPath(java.lang.String xpathExpr, boolean refreshXmlFirst) throws javax.xml.bind.JAXBException, XPathBinderAssociationIsPartialExceptionFetch JAXB Nodes matching an XPath (for example "//w:p"). If you have modified your JAXB objects (eg added or changed a w:p paragraph), you need to update the association. The problem is that this can only be done ONCE, owing to a bug in JAXB: see https://jaxb.dev.java.net/issues/show_bug.cgi?id=459 So this is left for you to choose to do via the refreshXmlFirst parameter.- Parameters:
xpathExpr-refreshXmlFirst-- Returns:
- Throws:
javax.xml.bind.JAXBExceptionXPathBinderAssociationIsPartialException
-
getJAXBNodesViaXPath
java.util.List<java.lang.Object> getJAXBNodesViaXPath(java.lang.String xpathExpr, java.lang.Object someJaxbElement, boolean refreshXmlFirst) throws javax.xml.bind.JAXBException, XPathBinderAssociationIsPartialExceptionFetch JAXB Nodes matching an XPath (for example ".//w:p" - note the dot, which is necessary for this sort of relative path). If you have modified your JAXB objects (eg added or changed a w:p paragraph), you need to update the association. The problem is that this can only be done ONCE, owing to a bug in JAXB: see https://jaxb.dev.java.net/issues/show_bug.cgi?id=459 So this is left for you to choose to do via the refreshXmlFirst parameter.- Parameters:
xpathExpr-someJaxbElement-refreshXmlFirst-- Returns:
- Throws:
javax.xml.bind.JAXBExceptionXPathBinderAssociationIsPartialException
-
getJAXBAssociationsForXPath
java.util.List<JAXBAssociation> getJAXBAssociationsForXPath(java.lang.String xpathExpr, boolean refreshXmlFirst) throws javax.xml.bind.JAXBException, XPathBinderAssociationIsPartialExceptionFetch DOM node / JAXB object pairs matching an XPath (for example "//w:p"). In JAXB, this association is partial; not all XML elements have associated JAXB objects, and not all JAXB objects have associated XML elements. If the XPath returns an element which isn't associated with a JAXB object, the element's pair will be null. If you have modified your JAXB objects (eg added or changed a w:p paragraph), you need to update the association. The problem is that this can only be done ONCE, owing to a bug in JAXB: see https://jaxb.dev.java.net/issues/show_bug.cgi?id=459 So this is left for you to choose to do via the refreshXmlFirst parameter.- Parameters:
binder-jaxbElement-xpathExpr-refreshXmlFirst-- Returns:
- Throws:
javax.xml.bind.JAXBExceptionXPathBinderAssociationIsPartialException- Since:
- 3.0.0
-
getJAXBAssociationsForXPath
java.util.List<JAXBAssociation> getJAXBAssociationsForXPath(java.lang.Object someJaxbElement, java.lang.String xpathExpr, boolean refreshXmlFirst) throws javax.xml.bind.JAXBException, XPathBinderAssociationIsPartialExceptionFetch DOM node / JAXB object pairs matching an XPath (for example ".//w:p" - note the dot, which is necessary for this sort of relative path). In JAXB, this association is partial; not all XML elements have associated JAXB objects, and not all JAXB objects have associated XML elements. If the XPath returns an element which isn't associated with a JAXB object, the element's pair will be null. If you have modified your JAXB objects (eg added or changed a w:p paragraph), you need to update the association. The problem is that this can only be done ONCE, owing to a bug in JAXB: see https://jaxb.dev.java.net/issues/show_bug.cgi?id=459 So this is left for you to choose to do via the refreshXmlFirst parameter.- Parameters:
binder-jaxbElement-xpathExpr-refreshXmlFirst-- Returns:
- Throws:
javax.xml.bind.JAXBExceptionXPathBinderAssociationIsPartialException- Since:
- 3.0.0
-