org.exist.dom
Class NodeSetHelper

java.lang.Object
  extended byorg.exist.dom.NodeSetHelper

public class NodeSetHelper
extends java.lang.Object

Collection of static methods operating on node sets.

Author:
wolf

Constructor Summary
NodeSetHelper()
           
 
Method Summary
static void copyChildren(org.w3c.dom.Document new_doc, org.w3c.dom.Node node, org.w3c.dom.Node new_node)
           
static org.w3c.dom.Node copyNode(org.w3c.dom.Document new_doc, org.w3c.dom.Node node)
           
static NodeSet directSelectAttributes(NodeSet candidates, QName qname, int contextId)
           
static NodeSet selectAncestorDescendant(NodeSet dl, NodeSet al, int mode, boolean includeSelf, int contextId)
          For two given sets of potential ancestor and descendant nodes, find those nodes from the descendant set that actually have ancestors in the ancestor set, i.e.
static NodeSet selectAncestors(NodeSet al, NodeSet dl, boolean includeSelf, int contextId)
          For two sets of potential ancestor and descendant nodes, return all the real ancestors having a descendant in the descendant set.
static NodeSet selectFollowing(NodeSet references, NodeSet candidates)
          TODO: doesn't work!!!
static NodeSet selectFollowingSiblings(NodeSet candidates, NodeSet references, int contextId)
          Select all nodes from the passed set of potential siblings, which are following siblings of the nodes in the other set.
static NodeSet selectParentChild(NodeSet dl, NodeSet al, int mode, int contextId)
          For two given sets of potential parent and child nodes, find those nodes from the child set that actually have parents in the parent set, i.e.
static NodeSet selectPreceding(NodeSet references, NodeSet candidates)
          TODO: doesn't work!!!
static NodeSet selectPrecedingSiblings(NodeSet candidates, NodeSet references, int contextId)
          Select all nodes from the passed set of potential siblings, which are preceding siblings of the nodes in the other set.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NodeSetHelper

public NodeSetHelper()
Method Detail

selectParentChild

public static NodeSet selectParentChild(NodeSet dl,
                                        NodeSet al,
                                        int mode,
                                        int contextId)
For two given sets of potential parent and child nodes, find those nodes from the child set that actually have parents in the parent set, i.e. the parent-child relationship is true. The method returns either the matching descendant or ancestor nodes, depending on the mode constant. If mode is NodeSet.DESCENDANT, the returned node set will contain all child nodes found in this node set for each parent node. If mode is NodeSet.ANCESTOR, the returned set will contain those parent nodes, for which children have been found.

Parameters:
dl - a node set containing potential child nodes
al - a node set containing potential parent nodes
mode - selection mode
contextId - used to track context nodes when evaluating predicate expressions. If contextId != Expression.NO_CONTEXT_ID, the current context will be added to each result of the of the selection.

selectAncestorDescendant

public static NodeSet selectAncestorDescendant(NodeSet dl,
                                               NodeSet al,
                                               int mode,
                                               boolean includeSelf,
                                               int contextId)
For two given sets of potential ancestor and descendant nodes, find those nodes from the descendant set that actually have ancestors in the ancestor set, i.e. the ancestor-descendant relationship is true. The method returns either the matching descendant or ancestor nodes, depending on the mode constant. If mode is NodeSet.DESCENDANT, the returned node set will contain all descendant nodes found in this node set for each ancestor. If mode is NodeSet.ANCESTOR, the returned set will contain those ancestor nodes, for which descendants have been found.

Parameters:
dl - a node set containing potential descendant nodes
al - a node set containing potential ancestor nodes
mode - selection mode
includeSelf - if true, check if the ancestor node itself is contained in the set of descendant nodes (descendant-or-self axis)
contextId - used to track context nodes when evaluating predicate expressions. If contextId != Expression.NO_CONTEXT_ID, the current context will be added to each result of the of the selection.

selectAncestors

public static NodeSet selectAncestors(NodeSet al,
                                      NodeSet dl,
                                      boolean includeSelf,
                                      int contextId)
For two sets of potential ancestor and descendant nodes, return all the real ancestors having a descendant in the descendant set.

Parameters:
al - node set containing potential ancestors
dl - node set containing potential descendants
includeSelf - if true, check if the ancestor node itself is contained in this node set (ancestor-or-self axis)
contextId - used to track context nodes when evaluating predicate expressions. If contextId != Expression.NO_CONTEXT_ID, the current context will be added to each result of the of the selection.

selectPrecedingSiblings

public static NodeSet selectPrecedingSiblings(NodeSet candidates,
                                              NodeSet references,
                                              int contextId)
Select all nodes from the passed set of potential siblings, which are preceding siblings of the nodes in the other set.

Parameters:
candidates - the node set to check
references - a node set containing potential siblings
contextId - used to track context nodes when evaluating predicate expressions. If contextId != Expression.NO_CONTEXT_ID, the current context will be added to each result of the of the selection.

selectFollowingSiblings

public static NodeSet selectFollowingSiblings(NodeSet candidates,
                                              NodeSet references,
                                              int contextId)
Select all nodes from the passed set of potential siblings, which are following siblings of the nodes in the other set.

Parameters:
candidates - the node set to check
references - a node set containing potential siblings
contextId - used to track context nodes when evaluating predicate expressions. If contextId != Expression.NO_CONTEXT_ID, the current context will be added to each result of the of the selection.

selectPreceding

public static NodeSet selectPreceding(NodeSet references,
                                      NodeSet candidates)
                               throws XPathException
TODO: doesn't work!!!

Throws:
XPathException

selectFollowing

public static NodeSet selectFollowing(NodeSet references,
                                      NodeSet candidates)
                               throws XPathException
TODO: doesn't work!!!

Throws:
XPathException

directSelectAttributes

public static NodeSet directSelectAttributes(NodeSet candidates,
                                             QName qname,
                                             int contextId)

copyChildren

public static final void copyChildren(org.w3c.dom.Document new_doc,
                                      org.w3c.dom.Node node,
                                      org.w3c.dom.Node new_node)

copyNode

public static final org.w3c.dom.Node copyNode(org.w3c.dom.Document new_doc,
                                              org.w3c.dom.Node node)


Copyright (C) Wolfgang Meier. All rights reserved.