List of utility methods to do XML Node Parent
boolean | isAnyNodeAncestorOf(ArrayList ancestorNodes, Node node) Checks if any of from the given list of nodes is an ancestor to another node int n = ancestorNodes.size(); for (int i = 0; i < n; i++) { Node ancestor = (Node) ancestorNodes.get(i); if (isAncestorOf(ancestor, node)) { return true; return false; ... |
boolean | isDescendant(Node test, Node target) is Descendant Node parent = test.getParentNode(); if (parent == null) return false; else if (parent.equals(target)) return true; return isDescendant(parent, target); |
boolean | isDescendantOrSelf(Node ctx, Node descendantOrSelf) Returns true if the descendantOrSelf is on the descendant-or-self axis of the context node. if (ctx == descendantOrSelf) { return true; Node parent = descendantOrSelf; while (true) { if (parent == null) { return false; if (parent == ctx) { return true; if (parent.getNodeType() == Node.ATTRIBUTE_NODE) { parent = ((Attr) parent).getOwnerElement(); } else { parent = parent.getParentNode(); |
boolean | isDescendantOrSelf(Node ctx, Node descendantOrSelf) Returns true if the descendantOrSelf is on the descendant-or-self axis of the context node. if (ctx == descendantOrSelf) { return true; Node parent = descendantOrSelf; while (true) { if (parent == null) { return false; if (parent == ctx) { return true; if (parent.getNodeType() == Node.ATTRIBUTE_NODE) { parent = ((Attr) parent).getOwnerElement(); } else { parent = parent.getParentNode(); |
Element | previousSiblingElement(Node node) previous Sibling Element for (Node tempNode = node.getPreviousSibling(); tempNode != null; tempNode = tempNode .getPreviousSibling()) { if (tempNode.getNodeType() == Node.ELEMENT_NODE) { return (Element) tempNode; return null; |
void | resolveLeafNodeValue(Node node) resolve Leaf Node Value if (node != null) { Element element = (Element) node; NodeList childNodeList = element.getChildNodes(); for (int j = 0; j < childNodeList.getLength(); j++) { Node chileNode = childNodeList.item(j); if (!chileNode.hasChildNodes()) { String nodeValue = resolveSystemProperty(chileNode.getTextContent()); childNodeList.item(j).setTextContent(nodeValue); ... |