Java Code Examples for org.w3c.dom.Node.getNodeValue()

The following are Jave code examples for showing how to use getNodeValue() of the org.w3c.dom.Node class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: s-store   File: ParsedInsertStmt.java   Source Code and License Vote up 6 votes
void parseInsertColumn(HashMap<Column, AbstractExpression> columns, Node columnNode, Database db, Table table) {
    NamedNodeMap attrs = columnNode.getAttributes();
    Node tableNameAttr = attrs.getNamedItem("table");
    Node columnNameAttr = attrs.getNamedItem("name");
    String tableName = tableNameAttr.getNodeValue();
    String columnName = columnNameAttr.getNodeValue();

    assert(tableName.equalsIgnoreCase(table.getTypeName()));
    Column column = table.getColumns().getIgnoreCase(columnName);

    AbstractExpression expr = null;
    NodeList children = columnNode.getChildNodes();
    for (int i = 0; i < children.getLength(); i++) {
        Node node = children.item(i);
        if (node.getNodeType() == Node.ELEMENT_NODE) {
            expr = parseExpressionTree(node, db);
            ExpressionUtil.assignLiteralConstantTypesRecursively(expr,
                    VoltType.get((byte)column.getType()));
            ExpressionUtil.assignOutputValueTypesRecursively(expr);
        }
    }

    columns.put(column, expr);
}
 
Example 2
Project: Svg2AndroidXml   File: Svg2Vector.java   Source Code and License Vote up 6 votes
private static void parseTransformation(SvgTree avg, Node nNode) {
    NamedNodeMap a = nNode.getAttributes();
    int len = a.getLength();

    for (int i = 0; i < len; i++) {
        Node n = a.item(i);
        String name = n.getNodeName();
        String value = n.getNodeValue();
        if (SVG_TRANSFORM.equals(name)) {
            if (value.startsWith("matrix(")) {
                value = value.substring("matrix(".length(), value.length() - 1);
                String[] sp = value.split(" ");
                for (int j = 0; j < sp.length; j++) {
                    avg.matrix[j] = Float.parseFloat(sp[j]);
                }
            }
        } else if (name.equals("y")) {
            Float.parseFloat(value);
        } else if (name.equals("x")) {
            Float.parseFloat(value);
        }

    }
}
 
Example 3
Project: defense-solutions-proofs-of-concept   File: CoTAdapterInbound.java   Source Code and License Vote up 6 votes
private String getAttribute(Node node, String attributeName)
		throws Exception {
	try {
		NamedNodeMap attributes = node.getAttributes();
		for (int i = 0; i < attributes.getLength(); i++) {
			Node attributeNode = attributes.item(i);
			if (attributeNode.getNodeName().equals(attributeName)) {
				return attributeNode.getNodeValue();
			}
		}
		return null;
	} catch (Exception e) {
		log.error(e);
		log.error(e.getStackTrace());
		throw (e);
	}
}
 
Example 4
Project: OpenJSharp   File: JPEGMetadata.java   Source Code and License Vote up 6 votes
private void mergeStandardTextNode(Node node)
    throws IIOInvalidTreeException {
    // Convert to comments.  For the moment ignore the encoding issue.
    // Ignore keywords, language, and encoding (for the moment).
    // If compression tag is present, use only entries with "none".
    NodeList children = node.getChildNodes();
    for (int i = 0; i < children.getLength(); i++) {
        Node child = children.item(i);
        NamedNodeMap attrs = child.getAttributes();
        Node comp = attrs.getNamedItem("compression");
        boolean copyIt = true;
        if (comp != null) {
            String compString = comp.getNodeValue();
            if (!compString.equals("none")) {
                copyIt = false;
            }
        }
        if (copyIt) {
            String value = attrs.getNamedItem("value").getNodeValue();
            COMMarkerSegment com = new COMMarkerSegment(value);
            insertCOMMarkerSegment(com);
        }
    }
}
 
Example 5
Project: lazycat   File: DomUtil.java   Source Code and License Vote up 5 votes
/**
 * Get the trimmed 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 = DomUtil.getChild(n, Node.TEXT_NODE);

	if (n1 == null)
		return null;

	String s1 = n1.getNodeValue();
	return s1.trim();
}
 
Example 6
Project: convertigo-engine   File: GetTextStatement.java   Source Code and License Vote up 5 votes
@Override
protected void addToScope(Scriptable scope, NodeList nodeList) {
	if (nodeList != null) {
		String nodeValue = null;
		if (nodeList.getLength() > 0) {
			Node node = nodeList.item(0);
			nodeValue = node.getNodeValue();
			if (node instanceof Element)
				nodeValue = ((Element) node).getTextContent();
		}
		scope.put(getVariableName(), scope, nodeValue);
	}
}
 
Example 7
Project: incubator-netbeans   File: RSSFeed.java   Source Code and License Vote up 5 votes
protected static String getTextContent(Node node) {
    Node child = node.getFirstChild();
    if( null == child )
        return null;
    
    return child.getNodeValue();
}
 
Example 8
Project: geomapapp   File: XML_Layer.java   Source Code and License Vote up 5 votes
private static Request parseMap(Node root) {
	Request request = new Request();

	Node name = root.getAttributes().getNamedItem("name");
	request.name = name != null ? name.getNodeValue() : null;

	Node url = root.getAttributes().getNamedItem("url");
	request.url = url != null ? url.getNodeValue() : null;

	Node srs = root.getAttributes().getNamedItem("srs");
	request.srs = srs != null ? srs.getNodeValue() : null;

	Node wesn = root.getAttributes().getNamedItem("wesn");
	if (wesn != null) {
		String[] s = wesn.getNodeValue().split(",");

		request.wesn = new double[4];
		for (int i = 0; i < 4; i++)
			request.wesn[i] = Double.parseDouble(s[i]);
	}

	List<Node> layers = getElements(root, "wms_layer");
	Iterator<Node> iter = layers.iterator();
	request.layers = new RequestLayer[layers.size()];
	for (int i = 0; i < layers.size(); i++)
		request.layers[i] = parseLayer(iter.next());

	return request;
}
 
Example 9
Project: openjdk-jdk10   File: Bug6760982.java   Source Code and License Vote up 5 votes
private static void _ProcessNode(Node n, int level) throws Exception {
    n.getAttributes();
    n.getChildNodes();

    // At this point, for JVM 1.6 and Xerces <= 1.3.1,
    // Test-XML.xml::mytest:Y's attribute is (already) bad.

    switch (n.getNodeType()) {

        case Node.TEXT_NODE:
            String str = n.getNodeValue().trim();

            /* ...Only print non-empty strings... */
            if (str.length() > 0) {
                String valStr = n.getNodeValue();

                _Println(valStr, level);
            }
            break;

        case Node.COMMENT_NODE:
            break;

        default: {
            String nodeNameStr = n.getNodeName();

            _Println(nodeNameStr + " (" + n.getClass() + "):", level);

            /* ...Print children... */
            _ProcessChildren(n, level);

            /* ...Print optional node attributes... */
            _PrintAttributes(n, level);
        }
    }
}
 
Example 10
Project: springboot-start   File: XMLUtil.java   Source Code and License Vote up 5 votes
public static Object getBean(String path, int i) {
    try {
        //创建文档对象
        DocumentBuilderFactory dFactory = DocumentBuilderFactory.newInstance();
        DocumentBuilder builder = dFactory.newDocumentBuilder();
        Document doc;
        doc = builder.parse(new File(ToolDirFile.getClassesPath(XMLUtil.class) + path));

        //获取包含类名的文本节点
        NodeList nl = doc.getElementsByTagName("className");
        Node classNode;
        if (0 == i) {
            classNode = nl.item(0).getFirstChild();
        }
        else {
            classNode = nl.item(1).getFirstChild();
        }

        String cName = classNode.getNodeValue();

        //通过类名生成实例对象并将其返回
        Class c = Class.forName(cName);
        Object obj = c.newInstance();
        return obj;
    }
    catch(Exception e){
        e.printStackTrace();
        return null;
    }
}
 
Example 11
Project: Java-APIs   File: VersionInfo.java   Source Code and License Vote up 5 votes
public VersionInfo(Element element) {
	logger.debug("Constructor - entry");

	NodeList nodeList = element.getChildNodes();
	for (int n = 0; n < nodeList.getLength(); n++) {
		Node node = nodeList.item(n);
		if (node.getNodeType() == Node.ELEMENT_NODE) {
			Element childElement = (Element) node;

			if ("VERSION".equals(childElement.getNodeName())) {
				String name = childElement.getAttribute("NAME");
				String revision = childElement.getAttribute("REVISION");
				if ("Compatible index structure version".equals(name)) {
					setIndexStructure(revision);
				} else if ("SES API version".equals(name)) {
					setApi(revision);
				} else if ("SES build".equals(name)) {
					setBuild(revision);
				} else {
					logger.trace("Unexpected version information: " + name + " (" + revision + ")");
				}
			} else {
				logger.trace("Unrecognized child node: '" + childElement.getNodeName() + "'");
			}
		} else if ((node.getNodeType() == Node.TEXT_NODE) && (node.getNodeValue() != null) && (node.getNodeValue().trim().length() > 0)) {
			logger.trace("Unexpected text node (" + this.getClass().getName() + "): '" + node.getNodeValue() + "'");
		}
	}
	NamedNodeMap namedNodeMap = element.getAttributes();
	if (namedNodeMap != null) {
		for (int a = 0; a < namedNodeMap.getLength(); a++) {
			Attr attributeNode = (Attr) namedNodeMap.item(a);
			logger.trace("Unrecognized attribute: '" + attributeNode.getName() + "'");
		}
	}

	logger.debug("Constructor - exit");
}
 
Example 12
Project: OpenJSharp   File: GIFMetadata.java   Source Code and License Vote up 5 votes
protected static String getAttribute(Node node, String name,
                                     String defaultValue, boolean required)
  throws IIOInvalidTreeException {
    Node attr = node.getAttributes().getNamedItem(name);
    if (attr == null) {
        if (!required) {
            return defaultValue;
        } else {
            fatal(node, "Required attribute " + name + " not present!");
        }
    }
    return attr.getNodeValue();
}
 
Example 13
Project: incubator-netbeans   File: JavaClassHyperlinkProcessor.java   Source Code and License Vote up 5 votes
@Override
public void process(HyperlinkEnv env) {
    String className = env.getValueString();
    Node n = env.getDocumentContext().getDocRoot().getNode().getAttributes().
            getNamedItem(HibernateMappingXmlConstants.PACKAGE_ATTRIB);//NOI18N
    String pack = n == null ? null : n.getNodeValue();
    if(pack!=null &&  pack.length()>0){
        if(!className.contains(".")){
            className = pack + "." +className;
        }
    }
    HibernateEditorUtil.findAndOpenJavaClass(className, env.getDocument());
}
 
Example 14
Project: lams   File: DomUtil.java   Source Code and License Vote up 5 votes
/** 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=DomUtil.getChild(n, Node.TEXT_NODE);

    if( n1==null ) return null;

    String s1=n1.getNodeValue();
    return s1.trim();
}
 
Example 15
Project: mi-firma-android   File: TriphaseData.java   Source Code and License Vote up 5 votes
/** Analiza el nodo con el listado de firmas.
 * @param signsNode Nodo con el listado de firmas.
 * @return Listado con la informaci&oacute;n de cada operaci&oacute;n de firma. */
private static List<TriSign> parseSignsNode(final Node signsNode) {

	final NodeList childNodes = signsNode.getChildNodes();

	final List<TriSign> signs = new ArrayList<TriSign>();
	int idx = nextNodeElementIndex(childNodes, 0);
	while (idx != -1) {
		final Node currentNode = childNodes.item(idx);

		String id = null;

		final NamedNodeMap nnm = currentNode.getAttributes();
		if (nnm != null) {
			final Node tmpNode = nnm.getNamedItem("Id"); //$NON-NLS-1$
			if (tmpNode != null) {
				id = tmpNode.getNodeValue();
			}
		}
		signs.add(
			new TriSign(
				parseParamsListNode(currentNode),
				id
			)
		);
		idx = nextNodeElementIndex(childNodes, idx + 1);
	}

	return signs;
}
 
Example 16
Project: Java-APIs   File: OMStructure.java   Source Code and License Vote up 4 votes
public OMStructure(Element element) {
	logger.debug("Constructor - entry");
	NodeList nodeList = element.getChildNodes();
	for (int n = 0; n < nodeList.getLength(); n++) {
		Node node = nodeList.item(n);
		if (node.getNodeType() == Node.ELEMENT_NODE) {
			Element childElement = (Element) node;
			if ("TERM_CLASSES".equals(childElement.getNodeName())) {
				setClassTypes(this.getList(childElement, "TERM_CLASS", new ClassTypeFactory()));
			} else if ("TERM_FACETS".equals(childElement.getNodeName())) {
				setFacets(this.getList(childElement, "FIELD", new FieldFactory()));
			} else if ("TERM_ATTRIBUTES".equals(childElement.getNodeName())) {
				setAttributes(this.getList(childElement, "TERM_ATTRIBUTE", new AttributeFactory()));
			} else if ("TERM_NOTES".equals(childElement.getNodeName())) {
				setNotes(this.getList(childElement, "TERM_NOTE", new NoteFactory()));
			} else if ("TERM_METADATA".equals(childElement.getNodeName())) {
				setChoices(this.getList(childElement, "METADATA_DEF", new ChoiceFactory()));
			} else if ("EQUIVALENCE_RELATIONS".equals(childElement.getNodeName())) {
				setEquivalenceRelations(this.getList(childElement, "RELATION_DEF", new RelationFactory()));
			} else if ("HIERARCHICAL_RELATIONS".equals(childElement.getNodeName())) {
				setHierarchicalRelations(this.getList(childElement, "RELATION_DEF", new RelationFactory()));
			} else if ("ASSOCIATIVE_RELATIONS".equals(childElement.getNodeName())) {
				setAssociativeRelations(this.getList(childElement, "RELATION_DEF", new RelationFactory()));
			} else if ("USERS".equals(childElement.getNodeName())) {
				setUsers(this.getList(childElement, "USER_DEF", new UserFactory()));
			} else {
				logger.trace("Unrecognized child node: '" + childElement.getNodeName() + "'");
			}
		} else if ((node.getNodeType() == Node.TEXT_NODE) && (node.getNodeValue() != null) && (node.getNodeValue().trim().length() > 0)) {
			logger.trace("Unexpected text node (" + this.getClass().getName() + "): '" + node.getNodeValue() + "'");
		}
	}

	NamedNodeMap namedNodeMap = element.getAttributes();
	if (namedNodeMap != null) {
		for (int a = 0; a < namedNodeMap.getLength(); a++) {
			Attr attributeNode = (Attr) namedNodeMap.item(a);
			logger.trace("Unrecognized attribute: '" + attributeNode.getName() + "'");
		}
	}

	logger.debug("Constructor - exit");
}
 
Example 17
Project: convertigo-eclipse   File: TwsDomTree.java   Source Code and License Vote up 4 votes
/**
 * Adds a node in the visual tree. This method is used by the @see fillDomTree method 
 *  
 * @param parent 	the parent (Can be the tree or a parent TreeItem)
 * @param node		the node to be added
 */
public boolean addNodeInTree(Object parent, Node node, IProgressMonitor monitor) {
	TreeItem tItem = (TreeItem) parent;
	String[] values = new String[2];
	tItem.setData(node);
	// calc the node text according to the node type
	switch (node.getNodeType()) {
	case Node.ELEMENT_NODE :
		int dec = 0;
		if (node.hasAttributes()) {// add a fake first node for 'Attributes' item
			tItem.setData("dec", new Integer(dec = 1));
		}
		Node[] childs = XMLUtils.toNodeArray(node.getChildNodes());
		tItem.setData("childs", childs);
		tItem.setItemCount(childs.length + dec);
		
		values[0] = node.getNodeName();
		values[1] = getTextValue(node);
		
		tItem.setText(values);
		tItem.setImage(imageNode);
		break;
	case Node.TEXT_NODE  :
		tItem.setImage(imageText);
		tItem.setText(node.getNodeValue().trim());
		break;
	case Node.ATTRIBUTE_NODE:
		tItem.setImage(imageAttrib);
		String str = node.getNodeName() + "=\"" + node.getNodeValue() + "\"";
		tItem.setText(new String[] {str, str});
		break;
	case Node.ENTITY_NODE:
		tItem.setText("[Entity]");
		break;
	case Node.ENTITY_REFERENCE_NODE :
		tItem.setText("[Entityref]");
		break;
	case Node.PROCESSING_INSTRUCTION_NODE :
		tItem.setText("[Pi]");
		break;
	case Node.COMMENT_NODE :
		tItem.setText("[Comment]");
		break;
	case Node.DOCUMENT_FRAGMENT_NODE :
		tItem.setText("[Docfgmt]");
		break;
	case Node.DOCUMENT_TYPE_NODE :
		tItem.setText("[Doctype]");
		break;
	case Node.NOTATION_NODE :
		tItem.setText("[Notation]");
		break;
	default: break;
	}
	
	return true;
}
 
Example 18
Project: javaide   File: ManifestMerger.java   Source Code and License Vote up 4 votes
private static int insertSourceMarker(@NonNull Node parent, @NonNull Node node,
        @NonNull File file, boolean after) {
    int insertCount = 0;
    Document doc = parent.getNodeType() ==
            Node.DOCUMENT_NODE ? (Document) parent : parent.getOwnerDocument();

    String comment;
    try {
        comment = SdkUtils.createPathComment(file, true);
    } catch (MalformedURLException e) {
        return insertCount;
    }

    Node prev = node.getPreviousSibling();
    String newline;
    if (prev != null && prev.getNodeType() == Node.TEXT_NODE) {
        // Duplicate indentation from previous line. Once we switch the merger
        // over to using the XmlPrettyPrinter, we won't need this.
        newline = prev.getNodeValue();
        int index = newline.lastIndexOf('\n');
        if (index != -1) {
            newline = newline.substring(index);
        }
    } else {
        newline = "\n";
    }

    if (after) {
        node = node.getNextSibling();
    }

    parent.insertBefore(doc.createComment(comment), node);
    insertCount++;

    // Can't add text nodes at the document level in Xerces, even though
    // it will happily parse these
    if (parent.getNodeType() != Node.DOCUMENT_NODE) {
        parent.insertBefore(doc.createTextNode(newline), node);
        insertCount++;
    }

    return insertCount;
}
 
Example 19
Project: convertigo-engine   File: Step.java   Source Code and License Vote up 4 votes
protected String getNodeValue(Node node) {
	if (node != null) {
		int len;
		int nodeType = node.getNodeType();
		switch (nodeType) {
			case Node.ELEMENT_NODE:
				if (sequence.getProject().isStrictMode()) {
					return XMLUtils.prettyPrintElement((Element)node, true, false);
				}
				else {
					len = node.getChildNodes().getLength();
					Node firstChild = node.getFirstChild();
					if (firstChild != null) {
						int firstChildType = firstChild.getNodeType();
						switch (firstChildType) {
							case Node.CDATA_SECTION_NODE:
							case Node.TEXT_NODE: 
								return ((len<2) ? firstChild.getNodeValue():XMLUtils.getNormalizedText(node));
							case Node.ELEMENT_NODE: 
								return XMLUtils.prettyPrintElement((Element)node, true, false);
							default: 
								return null;
						}
					} else {
						if (Engine.logBeans.isInfoEnabled())
							Engine.logBeans.warn("Applied XPath on step '"+ this +"' returned node with null value ('"+node.getNodeName()+"')");
						return null;
					}
				}
			case Node.CDATA_SECTION_NODE:
			case Node.TEXT_NODE:
				len = node.getChildNodes().getLength();
				return ((len<2) ? node.getNodeValue():XMLUtils.getNormalizedText(node));
			case Node.ATTRIBUTE_NODE:
				return node.getNodeValue();
			default:
				if (Engine.logBeans.isInfoEnabled())
					Engine.logBeans.warn("Applied XPath on step '"+ this +"' is not supported");
				return null;
		}
	}
	return null;
}
 
Example 20
Project: froog   File: Open.java   Source Code and License Vote up 4 votes
private static String obtenerNodoValor(String strTag, Element eNodo) {
    Node nValor = (Node) eNodo.getElementsByTagName(strTag).item(0).getFirstChild();
    return nValor.getNodeValue();
}