/** * Get the raw text content of a node or null if there is no text */ public static String getRawContent(Node n) { if (n == null) return null; Node n1 = DOMUtils.getChild(n, Node.TEXT_NODE); if (n1 == null) return null; String s1 = n1.getNodeValue(); return s1.trim(); }
/** * Get the first child's content ( ie it's included TEXT node ). */ public static String getChildContent(Node parent, String name) { Node first = parent.getFirstChild(); if (first == null) return null; for (Node node = first; node != null; node = node.getNextSibling()) { if (name.equals(node.getNodeName())) { return getContent(node); } } return null; }
/** * Get the next sibling with the same name and type */ public static Node getNext(Node current) { String name = current.getNodeName(); int type = current.getNodeType(); return getNext(current, name, type); }
Node child = DOMUtils.getChild(parent, Node.ELEMENT_NODE); if (attVal == null) && (elemName == null || elemName .equals(child.getNodeName())) && DOMUtils.getAttribute(child, attName) != null) child = getNext(child, elemName, Node.ELEMENT_NODE); && (elemName == null || elemName .equals(child.getNodeName())) && !attVal.equals(DOMUtils.getAttribute(child, attName))) child = getNext(child, elemName, Node.ELEMENT_NODE);
public String getText() { return DOMUtils.getRawContent(getCurrentElement()); }
public void invoke(MessageContext context) throws Exception { Document doc = (Document) context.getCurrentMessage().getProperty(DOMInHandler.DOM_MESSAGE); if (doc == null) { log.error("DOM Document was not found so the message could not be logged. " + "Please add DOMInHandler/DOMOutHandler to your flow!"); return; } ByteArrayOutputStream bos = new ByteArrayOutputStream(); DOMUtils.writeXml(doc.getDocumentElement(), bos); log.info(bos.toString()); } }
public String getElementText() throws XMLStreamException { getCurrentFrame().ended = true; currentEvent = END_ELEMENT; endElement(); String result = DOMUtils.getContent(content); // we should not return null according to the StAx API javadoc return result != null ? result : ""; }
/** * Get the trimed text content of a node or null if there is no text */ public static String getContent(Node n) { if (n == null) return null; Node n1 = DOMUtils.getChild(n, Node.TEXT_NODE); if (n1 == null) return null; String s1 = n1.getNodeValue(); return s1.trim(); }
public String getAttributeValue(String ns, String local) { Attr at; if (ns == null || ns.equals("")) at = getCurrentElement().getAttributeNode(local); else at = getCurrentElement().getAttributeNodeNS(ns, local); if (at == null) return null; return DOMUtils.getContent(at); }
/** * Set or replace the text value */ public static void setText(Node node, String val) { Node chld = DOMUtils.getChild(node, Node.TEXT_NODE); if (chld == null) { Node textN = node.getOwnerDocument().createTextNode(val); node.appendChild(textN); return; } // change the value chld.setNodeValue(val); }