/** * Extract nested text from a node. * Currently does not handle coalescing text nodes, CDATA sections, etc. * @param parent a parent element * @return the nested text, or null if none was found * * @since 8.4 */ public static String findText(Node parent) { NodeList l = parent.getChildNodes(); for (int i = 0; i < l.getLength(); i++) { if (l.item(i).getNodeType() == Node.TEXT_NODE) { Text text = (Text) l.item(i); return text.getNodeValue(); } } return null; }
/** * Find all direct child elements of an element. * Children which are all-whitespace text nodes or comments are ignored; others cause * an exception to be thrown. * @param parent a parent element in a DOM tree * @return a list of direct child elements (may be empty) * @throws IllegalArgumentException if there are non-element children besides whitespace * * @since 8.4 */ public static List<Element> findSubElements(Element parent) throws IllegalArgumentException { NodeList l = parent.getChildNodes(); List<Element> elements = new ArrayList<Element>(l.getLength()); for (int i = 0; i < l.getLength(); i++) { Node n = l.item(i); if (n.getNodeType() == Node.ELEMENT_NODE) { elements.add((Element) n); } else if (n.getNodeType() == Node.TEXT_NODE) { String text = ((Text) n).getNodeValue(); if (text.trim().length() > 0) { throw new IllegalArgumentException("non-ws text encountered in " + parent + ": " + text); // NOI18N } } else if (n.getNodeType() == Node.COMMENT_NODE) { // OK, ignore } else { throw new IllegalArgumentException("unexpected non-element child of " + parent + ": " + n); // NOI18N } } return elements; }
for (int j = 0; j < nl2.getLength(); j++) { Node n = nl2.item(j); if (n instanceof Text && ((Text) n).getNodeValue().trim().length() == 0) { e.removeChild(n);
/** * Method getVal * * @param localname * @param namespace * @return The biginteger contained in the given element * @throws Base64DecodingException */ public BigInteger getBigIntegerFromChildElement( String localname, String namespace ) throws Base64DecodingException { return Base64.decodeBigIntegerFromString( XMLUtils.selectNodeText( getFirstChild(), namespace, localname, 0 ).getNodeValue() ); }
/** * Retrieves a String representation of the actual value stored * * @return String representation of the actual value stored */ public String getStringValue() { return _value.getNodeValue(); }
@Override public boolean isWhitespaceNode(Text text) { String value = text.getNodeValue(); if (null == value) { return false; } else { return value.trim().equals(""); } }
public boolean isWhitespaceNode(Text text) { String value = text.getNodeValue(); if (null == value) { return false; } else { return value.trim().equals(""); } }
private String getTextValue(final Node node) { final Node first = node.getFirstChild(); if (first != null) { return ((Text) first).getNodeValue().trim(); } else { return null; } } }
public boolean isWhitespaceNode(Text text) { String value = text.getNodeValue(); if (null == value) { return false; } else { return value.trim().equals(""); } }
public boolean isWhitespaceNode(Text text) { String value = text.getNodeValue(); if (null == value) { return false; } else { return value.trim().equals(""); } }
public void doWalk(XMLWalker rootWalker, ContentHandler contentHandler, Object value, String attributeName, List walkedInstances) throws SAXException { Text node = (Text) value; String characters = node.getNodeValue(); contentHandler.characters(characters.toCharArray(), 0, characters.length()); }
static public String getTextValue(Node node) { Node first = node.getFirstChild(); if (first != null) { Text text = (Text) node.getFirstChild(); return text.getNodeValue().trim(); } else return null; }
/** * copied from AnnotationViewerDialog. */ static public String getTextValue(Node node) { Node first = node.getFirstChild(); if (first != null) { Text text = (Text) node.getFirstChild(); return text.getNodeValue().trim(); } else return null; }
/** * Assumes node has a text field and extracts its value. JMP */ static public String getTextValue(Node node) { Node first = node.getFirstChild(); if (first != null) { Text text = (Text) node.getFirstChild(); return text.getNodeValue().trim(); } else return null; }
/** * @see org.n52.security.common.xml.DocumentVisitorAdapter#postVisit(org.w3c.dom.Text) */ public void visit(Text text) { String value = text.getNodeValue(); if (value != null && m_matcher.reset(value).matches()) { m_requiredNamespacePrefixes.add(m_matcher.group(1)); } }
@Override public void visit(Text text) { if (text.getParentNode().equals(documentElement)) { return; } requestParameters.put(text.getParentNode().getLocalName().toUpperCase(), text.getNodeValue()); }
public void writeSingleValue(Object attributeValue, Object parent, XMLRecord row, AbstractSession session) { if (((XMLField)this.getField()).getLastXPathFragment().nameIsText()) { if (attributeValue instanceof Text) { attributeValue = ((Text)attributeValue).getNodeValue(); } } row.put(getField(), attributeValue); }
public void writeSingleValue(Object attributeValue, Object parent, XMLRecord row, AbstractSession session) { if (((XMLField)this.getField()).getLastXPathFragment().nameIsText()) { if (attributeValue instanceof Text) { attributeValue = ((Text)attributeValue).getNodeValue(); } } row.put(getField(), attributeValue); }
public void writeSingleValue(Object attributeValue, Object parent, XMLRecord row, AbstractSession session) { if (((XMLField)this.getField()).getLastXPathFragment().isAttribute()) { if (attributeValue instanceof Attr) { attributeValue = ((Attr)attributeValue).getValue(); } } else if (((XMLField)this.getField()).getLastXPathFragment().nameIsText()) { if (attributeValue instanceof Text) { attributeValue = ((Text)attributeValue).getNodeValue(); } } row.put(getField(), attributeValue); }
public void writeSingleValue(Object attributeValue, Object parent, XMLRecord row, AbstractSession session) { if (((XMLField)this.getField()).getLastXPathFragment().isAttribute()) { if (attributeValue instanceof Attr) { attributeValue = ((Attr)attributeValue).getValue(); } } else if (((XMLField)this.getField()).getLastXPathFragment().nameIsText()) { if (attributeValue instanceof Text) { attributeValue = ((Text)attributeValue).getNodeValue(); } } row.put(getField(), attributeValue); }