private void parse(Document doc) { NodeList nodeList = doc.getChildNodes(); for (int count = 0; count < nodeList.getLength(); count++) { Node node = nodeList.item(count); if (node.getNodeType() == Node.ELEMENT_NODE && node.hasChildNodes()) { parseAttrList(node.getChildNodes()); } } }
@Override public int jjtGetNumChildren() { return node.hasChildNodes() ? node.getChildNodes().getLength() : 0; }
public static void removeChilds(Node node) { while (node.hasChildNodes()) node.removeChild(node.getFirstChild()); }
/** * Check if row contains non-empty cells * * @param rowElem * @return */ protected boolean isRowEmpty( TableTableRowElement rowElem ) { NodeList cells = rowElem.getChildNodes(); int cellsLen = cells.getLength(); for ( int j = 0; j < cellsLen; j++ ) { // iterate over cells Node cell = cells.item( j ); if ( cell instanceof TableTableCellElement ) { if ( cell.hasChildNodes() ) { return false; } } } return true; }
/** * Recursively removes all comment nodes from the subtree. * * @see #simplify */ static public void removeComments(Node parent) { Node child = parent.getFirstChild(); while (child != null) { Node nextSibling = child.getNextSibling(); if (child.getNodeType() == Node.COMMENT_NODE) { parent.removeChild(child); } else if (child.hasChildNodes()) { removeComments(child); } child = nextSibling; } }
public static String text(Node node) { if (node.getNodeType() == Node.TEXT_NODE || node.getNodeType() == Node.CDATA_SECTION_NODE) { return node.getNodeValue(); } if (node.hasChildNodes()) { return text(node.getChildNodes()); } return ""; }
boolean hasChildren = node.hasChildNodes(); if (hasChildren != node2.hasChildNodes()) { throw ActiveMQClientMessageBundle.BUNDLE.oneNodeHasChildren(); NodeList nl = node.getChildNodes(); NodeList nl2 = node2.getChildNodes();
/** * Determine whether the node has any children. * <p>Note: the result is equivalent to * <code>getEnumeration(Axis.CHILD, AnyNodeTest.getInstance()).hasNext()</code></p> */ public boolean hasChildNodes() { // An attribute node has child text nodes synchronized (docWrapper.docNode) { return node.getNodeType() != Node.ATTRIBUTE_NODE && node.hasChildNodes(); } }
private void parseAttrList(NodeList nodeList) { for (int count = 0; count < nodeList.getLength(); count++) { Node tempNode = nodeList.item(count); if (tempNode.getNodeType() == Node.ELEMENT_NODE && tempNode.hasAttributes() && tempNode.hasChildNodes()) { String name = null; NamedNodeMap nodeMap = tempNode.getAttributes(); for (int i = 0; i < nodeMap.getLength(); i++) { Node node = nodeMap.item(i); if (node.getNodeName().equals("name")) { name = node.getNodeValue(); break; } } if (name != null && tempNode.getNodeName().equals("attr")) { parseValues(name, tempNode.getChildNodes()); } else { parseAttrList(tempNode.getChildNodes()); } } } }
protected int findNrColumns( OdfTableRow row ) { int result = roughNrOfCols; if ( row != null ) { NodeList cells = row.getOdfElement().getChildNodes(); if ( cells != null && cells.getLength() > 0 ) { int cellLen = cells.getLength(); for ( int i = cellLen - 1; i >= 0; i-- ) { Node cell = cells.item( i ); if ( cell instanceof TableTableCellElement ) { if ( !cell.hasChildNodes() ) { // last cell is empty - remove it from counter result -= ( (TableTableCellElement) cell ).getTableNumberColumnsRepeatedAttribute(); } else { // get first non-empty cell from the end, break break; } } } } } return result; }
/** * Recursively removes all processing instruction nodes from the subtree. * * @see #simplify */ static public void removePIs(Node parent) { Node child = parent.getFirstChild(); while (child != null) { Node nextSibling = child.getNextSibling(); if (child.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE) { parent.removeChild(child); } else if (child.hasChildNodes()) { removePIs(child); } child = nextSibling; } }
public static String text(Node node) { if (node.getNodeType() == Node.TEXT_NODE || node.getNodeType() == Node.CDATA_SECTION_NODE) { return node.getNodeValue(); } if (node.hasChildNodes()) { return text(node.getChildNodes()); } return ""; }
public static Set<Node> findChildElementsByTag(Node node, String tag) { final Set<Node> result = new LinkedHashSet<>(); for (Node child = node.getFirstChild(); child != null; child = child.getNextSibling()) { if (tag.equals(child.getNodeName())) { result.add(child); } else if (child.hasChildNodes()) { result.addAll(findChildElementsByTag(child, tag)); } } return result; }
public String getSample( String strFunctionName, String strFunctionNameWithArgs ) { String sRC = "// Sorry, no Script available for " + strFunctionNameWithArgs; NodeList nl = dom.getElementsByTagName( "jsFunction" ); for ( int i = 0; i < nl.getLength(); i++ ) { if ( nl.item( i ).getAttributes().getNamedItem( "name" ).getNodeValue().equals( strFunctionName ) ) { Node elSample = ( (Element) nl.item( i ) ).getElementsByTagName( "sample" ).item( 0 ); if ( elSample.hasChildNodes() ) { return ( elSample.getFirstChild().getNodeValue() ); } } } return sRC; }
if (commentsNodes != null && commentsNodes.getLength() > 0 && commentsNodes.item(0).hasChildNodes()) comments = commentsNodes.item(0).getTextContent(); else comments = null; NodeList tableNodes = ((Element)tablesNodes.item(0)).getElementsByTagName("table"); for (int i = 0; i < tableNodes.getLength(); ++i) { Node tableNode = tableNodes.item(i); TableMeta tableMeta = new TableMeta(tableNode);
n!=null && ENTITY_REFERENCE_NODE == n.getNodeType(); n=n.getParentNode()) while(n!=null && ENTITY_REFERENCE_NODE == n.getNodeType()) if(n.hasChildNodes()) n=n.getFirstChild(); else n=n.getNextSibling(); int ntype=n.getNodeType(); if(TEXT_NODE != ntype && CDATA_SECTION_NODE != ntype) n=null;
/** * Returns the text value of this block. **/ public String getText() { if (_node.getNodeType() == Node.TEXT_NODE) { return _node.getNodeValue().trim(); } else if (_node == null || !_node.hasChildNodes()) { return ""; } else { return NodeUtils.asText( _node.getChildNodes() ).trim(); } }
if (currentNode.hasChildNodes()) { currentNode.getFirstChild()); } else {
private static void getMatchingNodes(Node node, String[] nodePath, int cur, List<Node> res) { if (cur < 0 || cur >= nodePath.length) return; boolean last = (cur == nodePath.length-1); String name = nodePath[cur]; if (node.hasChildNodes()) { NodeList children = node.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { Node c = children.item(i); if (name.equals(c.getNodeName())) { if (last) { res.add(c); } else { getMatchingNodes(c, nodePath, cur+1, res); } } } } }
n!=null && ENTITY_REFERENCE_NODE == n.getNodeType(); n=n.getParentNode()) while(n!=null && ENTITY_REFERENCE_NODE == n.getNodeType()) if(n.hasChildNodes()) n=n.getFirstChild(); else n=n.getNextSibling(); int ntype=n.getNodeType(); if(TEXT_NODE != ntype && CDATA_SECTION_NODE != ntype) n=null;