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
,ActiveSource
,TreeInfo
public class DOM4JDocumentWrapper extends GenericTreeInfo implements ActiveSource
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 void
deliver(Receiver receiver, ParseOptions options)
Implement ActiveSource by delivering the document to a supplied receiverstatic 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 anyNodeInfo
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
-
-
-
-
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 documentbaseURI
- The base URI for all the nodes in the documentconfig
- The Saxon configuration
-
-
Method Detail
-
deliver
public void deliver(Receiver receiver, ParseOptions options) throws XPathException
Implement ActiveSource by delivering the document to a supplied receiver- Specified by:
deliver
in interfaceActiveSource
- Parameters:
receiver
- the receiver to which events representing the parsed XML document will be sentoptions
- options for parsing the source- Throws:
XPathException
- if things don't work out
-
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 interfaceTreeInfo
- Overrides:
selectID
in classGenericTreeInfo
- Parameters:
id
- the required ID valuegetParent
- 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 searchednode
- a node to be sought within this subtree- Returns:
- the parent of the sought node if it is found; otherwise null
-
-