@Test public void testGetParent() throws Exception { final String xpath = "//OBJBLOCK"; final List<NodeInfo> nodes = getXpathItems(xpath, rootNode); assertEquals("Invalid number of nodes", 1, nodes.size()); final AbstractNode parent = (AbstractNode) nodes.get(0).getParent(); assertEquals("Invalid token type", TokenTypes.CLASS_DEF, parent.getTokenType()); }
public final NodeInfo next() { if (atStart) { atStart = false; if (includeSelf) { return current; } } return current = current == null ? null : current.getParent(); }
public void advance() { if (atStart) { atStart = false; if (includeSelf) { return; } } current = (current == null ? null : current.getParent()); }
public void advance() { if (atStart) { atStart = false; if (includeSelf) { return; } } current = (current == null ? null : current.getParent()); }
/** * Set the root node of the tree * @param root the root node (not necessarily a document node) * @throws java.lang.IllegalArgumentException if the supplied node is not parentless */ public void setRootNode(NodeInfo root) { if (root.getParent() != null) { throw new IllegalArgumentException("The root node of a tree must be parentless"); } this.root = root; }
/** * Set the root node of the tree * @param root the root node (not necessarily a document node) * @throws java.lang.IllegalArgumentException if the supplied node is not parentless */ public void setRootNode(NodeInfo root) { if (root.getParent() != null) { throw new IllegalArgumentException("The root node of a tree must be parentless"); } this.root = root; }
public String getInheritedAttribute(NodeInfo element, String localName) { while (element != null) { String val = element.getAttributeValue("", localName); if (val != null) { return val; } element = element.getParent(); } return null; }
/** * Find the parent node of this node. * * @return The Node object describing the containing element or root node. */ public Node getParentNode() { return wrap(node.getParent()); }
/** * Get the NodeInfo object representing the parent of this node */ public NodeInfo getParent() { if (parent==null) { NodeInfo realParent = node.getParent(); if (realParent != null) { parent = makeWrapper(realParent, docWrapper, null); } } return parent; }
/** * Find the parent node of this node. * * @return The Node object describing the containing element or root node. */ public Node getParentNode() { return wrap(node.getParent()); }
private String getDefaultCollationName(NodeInfo element) { while (element != null) { String coll = element.getAttributeValue("", "defaultCollation"); if (coll != null) { return coll; } element = element.getParent(); } return NamespaceConstant.CODEPOINT_COLLATION_URI; }
private boolean isPreserved(NodeInfo nextRealNode) { if (nextRealNode.getNodeKind() != Type.TEXT) { return true; } NodeInfo actualParent = parent == null ? nextRealNode.getParent() : parent.node; return isPreservedNode(nextRealNode, (SpaceStrippedDocument)docWrapper, actualParent); }
private boolean hasMatchingAncestor(NodeInfo anchor, NodeInfo anc, XPathContext context) throws XPathException { while (anc != null) { if (upperPattern.matchesBeneathAnchor(anc, anchor, context)) { return true; } if (anc.equals(anchor)) { return false; } anc = anc.getParent(); } return false; }
/** * Get the parent of this node * * @return the parent of this node (a document or element node), or null if this node has no parent. */ public XdmNode getParent() { NodeInfo p = getUnderlyingNode().getParent(); return p == null ? null : (XdmNode) XdmValue.wrap(p); }
/** * Get the parent of this node * * @return the parent of this node (a document or element node), or null if this node has no parent. */ public XdmNode getParent() { NodeInfo p = getUnderlyingNode().getParent(); return p == null ? null : (XdmNode) XdmValue.wrap(p); }
private boolean hasMatchingAncestor(NodeInfo anchor, NodeInfo anc, XPathContext context) throws XPathException { while (anc != null) { if (upperPattern.matchesBeneathAnchor(anc, anchor, context)) { return true; } if (anc.equals(anchor)) { return false; } anc = anc.getParent(); } return false; }
public BooleanValue call(XPathContext context, Sequence[] arguments) throws XPathException { NodeInfo val = (NodeInfo) arguments[0].head(); NodeInfo parent = val.getParent(); return BooleanValue.get( parent == null || parent.getNodeKind() == Type.DOCUMENT || val.getDeclaredNamespaces(NamespaceBinding.EMPTY_ARRAY).length > 0); }
@Override protected boolean isIncludedInCopy(NodeInfo sourceNode) { switch (sourceNode.getNodeKind()) { case Type.ATTRIBUTE: case Type.NAMESPACE: return isIncludedInCopy(sourceNode.getParent()); default: return Navigator.isAncestorOrSelf(pivot, sourceNode) || Navigator.isAncestorOrSelf(sourceNode, pivot); } }