Package net.sf.saxon.option.dom4j

## Class DOM4JDocumentWrapper

- java.lang.Object
- - net.sf.saxon.om.GenericTreeInfo
  - - net.sf.saxon.option.dom4j.DOM4JDocumentWrapper

- All Implemented Interfaces:
    `javax.xml.transform.Source`, `TreeInfo`

      public class DOM4JDocumentWrapper
      extends GenericTreeInfo

  TreeInfo class for a virtual tree that wraps a DOM4J tree

- - ### Field Summary

    - ### Fields inherited from class net.sf.saxon.om.GenericTreeInfo

      `root`

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `DOM4JDocumentWrapper​(org.dom4j.Document doc, java.lang.String baseURI, Configuration config)` | Create a Saxon wrapper for a dom4j document

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `static org.dom4j.Branch` | `searchForParent​(org.dom4j.Branch subtree, org.dom4j.Node node)` | DOM4J does not guarantee to provide the parent of a node, but XDM requires this.
    `NodeInfo` | `selectID​(java.lang.String id, boolean getParent)` | Get the element with a given ID, if any
    `NodeInfo` | `wrap​(org.dom4j.Node node)` | Wrap a node in the dom4j document.

    - ### Methods inherited from class net.sf.saxon.om.GenericTreeInfo

      `getConfiguration, getDocumentNumber, getPublicId, getRootNode, getSpaceStrippingRule, getSystemId, getUnparsedEntity, getUnparsedEntityNames, getUserData, isStreamed, setConfiguration, setDocumentNumber, setRootNode, setSpaceStrippingRule, setSystemId, setUserData`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface javax.xml.transform.Source

      `isEmpty`

    - ### Methods inherited from interface net.sf.saxon.om.TreeInfo

      `isMutable, isTyped`

- - ### Constructor Detail

    - #### DOM4JDocumentWrapper

          public DOM4JDocumentWrapper​(org.dom4j.Document doc,
                                      java.lang.String baseURI,
                                      Configuration config)

      Create a Saxon wrapper for a dom4j document
      Parameters:
        `doc` - The dom4j document
        `baseURI` - The base URI for all the nodes in the document
        `config` - The Saxon configuration

  - ### Method Detail

    - #### wrap

          public NodeInfo wrap​(org.dom4j.Node node)

      Wrap a node in the dom4j document.
      Parameters:
        `node` - The node to be wrapped. This must be a node in the same document (the system does not check for this).
      Returns:
        the wrapping NodeInfo object

    - #### selectID

          public NodeInfo selectID​(java.lang.String id,
                                   boolean getParent)

      Get the element with a given ID, if any
      Specified by:
        `selectID` in interface `TreeInfo`
      Overrides:
        `selectID` in class `GenericTreeInfo`
      Parameters:
        `id` - the required ID value
        `getParent` - true if the parent of the element having ID type is required
      Returns:
        null: dom4j does not provide any information about attribute types.

    - #### searchForParent

          public static org.dom4j.Branch searchForParent​(org.dom4j.Branch subtree,
                                                         org.dom4j.Node node)

      DOM4J does not guarantee to provide the parent of a node, but XDM requires this. In extremis, if we need the parent of a node and it is not known, we search the document looking for it. This is (fortunately!) very rarely necessary. One situation where we know it is needed is to find the parent of a processing instruction whose parent is in fact the document node.
      Parameters:
        `subtree` - the root of a subtree to be searched
        `node` - a node to be sought within this subtree
      Returns:
        the parent of the sought node if it is found; otherwise null