@Test public void testRootOfElementNode() throws Exception { final String xpath = "//OBJBLOCK"; final List<NodeInfo> nodes = getXpathItems(xpath, rootNode); assertEquals("Invalid number of nodes", 1, nodes.size()); final AbstractNode root = (AbstractNode) nodes.get(0).getRoot(); assertEquals("Invalid token type", TokenTypes.EOF, root.getTokenType()); assertTrue("Should return true, because selected node is RootNode", root instanceof RootNode); }
/** * Protected constructor: create a virtual copy of a node * * @param base the node in the source tree to which the new node should correspond * @param pivot the pivot node is the node supplied as argument to the snapshot() function; the snapshot * includes all ancestors of this node, and all descendants of this node (plus their attributes * and namespaces) */ protected SnapshotNode(NodeInfo base, NodeInfo pivot) { super(base, pivot.getRoot()); this.pivot = pivot; }
/** * Get the root node of the tree containing this node * * @return the NodeInfo representing the top-level ancestor of this node. * This will not necessarily be a document node */ public NodeInfo getRoot() { return element.getRoot(); }
/** * Get the root node of the tree containing this node * * @return the NodeInfo representing the top-level ancestor of this node. * This will not necessarily be a document node */ public NodeInfo getRoot() { return element.getRoot(); }
/** * Get the root node of the tree containing this node * * @return the NodeInfo representing the top-level ancestor of this node. * This will not necessarily be a document node */ public NodeInfo getRoot() { return element.getRoot(); }
/** * Get the root node of the tree containing this node * * @return the NodeInfo representing the top-level ancestor of this node. * This will not necessarily be a document node */ public NodeInfo getRoot() { return element.getRoot(); }
/** * Protected constructor: create a virtual copy of a node * * @param base the node in the source tree to which the new node should correspond * @param pivot the pivot node is the node supplied as argument to the snapshot() function; the snapshot * includes all ancestors of this node, and all descendants of this node (plus their attributes * and namespaces) */ protected SnapshotNode(NodeInfo base, NodeInfo pivot) { super(base, pivot.getRoot()); this.pivot = pivot; }
/** * Return the <code>Document</code> object associated with this node. */ public Document getOwnerDocument() { return (Document) wrap(node.getRoot()); }
/** * Get the root node * * @return the NodeInfo representing the root of this tree */ /*@NotNull*/ public NodeInfo getRoot() { return getParent().getRoot(); }
/** * Get the root node of the tree (not necessarily a document node) * * @return the NodeInfo representing the root of this tree */ public NodeInfo getRoot() { NodeInfo parent = getParent(); if (parent == null) { return this; // doesn't happen - parentless attributes are represented by the Orphan class } else { return parent.getRoot(); } }
/** * Evaluate in a general context */ public Item evaluateItem(XPathContext c) throws XPathException { NodeInfo start = (NodeInfo)argument[0].evaluateItem(c); if (start==null) { return null; } return start.getRoot(); }
/** * Return the <code>Document</code> object associated with this node. */ public Document getOwnerDocument() { return (Document) wrap(node.getRoot()); }
/** * Evaluate in a general context */ public Item evaluateItem(XPathContext c) throws XPathException { NodeInfo start = (NodeInfo)argument[0].evaluateItem(c); if (start==null) { return null; } return start.getRoot(); }
/** * Get the root node * * @return the NodeInfo representing the root of this tree */ /*@NotNull*/ public NodeInfo getRoot() { return getParent().getRoot(); }
/** * Get the root node * @return the NodeInfo representing the logical root of the tree. For this tree implementation the * root will either be a document node or an element node. */ public NodeInfo getRoot() { NodeInfo parent = getParent(); if (parent == null) { return this; } else { return parent.getRoot(); } }
/** * Evaluate in a general context */ public Item evaluateItem(XPathContext c) throws XPathException { NodeInfo start = (NodeInfo)argument[0].evaluateItem(c); if (start==null) { return null; } return start.getRoot(); }
/** * Get the root of the tree containing this node (which may or may not be a document node) * * @return the root of the tree containing this node. Returns this node itself if it has no parent. * @since 9.9 */ public XdmNode getRoot() { NodeInfo p = getUnderlyingNode().getRoot(); return p == null ? null : (XdmNode) XdmValue.wrap(p); }
/** * Get the root of the tree containing this node (which may or may not be a document node) * * @return the root of the tree containing this node. Returns this node itself if it has no parent. * @since 9.9 */ public XdmNode getRoot() { NodeInfo p = getUnderlyingNode().getRoot(); return p == null ? null : (XdmNode) XdmValue.wrap(p); }
private static NodeInfo getContextRoot(XPathContext context) throws XPathException { Item contextItem = context.getContextItem(); if (contextItem == null) { throw new XPathException("Cannot call the key() function when there is no context item", "XTDE1270", context); } else if (!(contextItem instanceof NodeInfo)) { throw new XPathException("Cannot call the key() function when the context item is not a node", "XTDE1270", context); } return ((NodeInfo) contextItem).getRoot(); }
private static NodeInfo getContextRoot(XPathContext context) throws XPathException { Item contextItem = context.getContextItem(); if (contextItem == null) { throw new XPathException("Cannot call the key() function when there is no context item", "XTDE1270", context); } else if (!(contextItem instanceof NodeInfo)) { throw new XPathException("Cannot call the key() function when the context item is not a node", "XTDE1270", context); } return ((NodeInfo) contextItem).getRoot(); }