当前位置: 首页>>代码示例>>Java>>正文


Java Node.setTextContent方法代码示例

本文整理汇总了Java中org.w3c.dom.Node.setTextContent方法的典型用法代码示例。如果您正苦于以下问题:Java Node.setTextContent方法的具体用法?Java Node.setTextContent怎么用?Java Node.setTextContent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.w3c.dom.Node的用法示例。


在下文中一共展示了Node.setTextContent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setPropsForCompile

import org.w3c.dom.Node; //导入方法依赖的package包/类
/**
 * Description: Editing the xml file for compiling projects.
 * @param init path to the xml file
 * @param build path to the build directory
 * @param src  path to the source directory
 */
public static void setPropsForCompile(String init ,String build, String src) {
    try {
        String filepath = init;
        DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
        DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
        Document doc = docBuilder.parse(filepath);
        
        // get project 
        //Node project = doc.getFirstChild();
        Node prop1 = doc.getElementsByTagName("property").item(0);
        Node prop2 = doc.getElementsByTagName("property").item(1);

        NamedNodeMap srcAttr = prop1.getAttributes();
        Node srcName = srcAttr.getNamedItem("location");
        srcName.setTextContent(src);
        
        NamedNodeMap buildAttr = prop2.getAttributes();
        Node buildName = buildAttr.getNamedItem("location");
        buildName.setTextContent(build);
        
        
        updateBuildFile( filepath, doc);
        
    } catch (Exception exc) {}
}
 
开发者ID:bufferhe4d,项目名称:call-IDE,代码行数:32,代码来源:BuildSys.java

示例2: encode

import org.w3c.dom.Node; //导入方法依赖的package包/类
public String encode(ResultSet rs) throws Exception {
	ResultSetMetaData rsmd;
	rsmd = rs.getMetaData();
	
	DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
	
	DocumentBuilder db = dbf.newDocumentBuilder();
	
	Document doc = db.newDocument();

	Element ele = doc.createElement("result");
	Integer count = 0;
	while(rs.next()){
		count++;
		Node rowNode = doc.createElement("row"); 
		for (int i=1; i<= rsmd.getColumnCount(); i++){
			 Node colNode = doc.createElement(rsmd.getColumnName(i)) ;
			 colNode.setTextContent(rs.getObject(colNode.getNodeName()).toString());
			 rowNode.appendChild(colNode);
		}
		ele.appendChild(rowNode);
	}
	ele.setAttribute("size", count.toString());
	doc.appendChild(ele);
	return toXmlString(doc);
}
 
开发者ID:manikmagar,项目名称:adobe-air-db-connector,代码行数:27,代码来源:XmlEncoder.java

示例3: trimWhiteSpace

import org.w3c.dom.Node; //导入方法依赖的package包/类
public static void trimWhiteSpace(Node node) {
    NodeList children = node.getChildNodes();
    int count = children.getLength();
    for (int i = 0; i < count; ++i) {
        Node child = children.item(i);
        if (child.getNodeType() == Node.TEXT_NODE) {
            child.setTextContent(child.getTextContent().trim());
        }
        trimWhiteSpace(child);
    }
}
 
开发者ID:intuit,项目名称:karate,代码行数:12,代码来源:XmlUtils.java

示例4: updateParamValue

import org.w3c.dom.Node; //导入方法依赖的package包/类
/**
    * Remove the tool's applicationContext entry from the param-value node of the context-param entry.
    * Should find and remove all the matching entries (should it somehow have have got in there m
    * 
    * @param doc
    * @param children
    * @param childNode
    */
   @Override
   protected void updateParamValue(Document doc, Node contextParamElement) {

NodeList valueChildren = contextParamElement.getChildNodes();
for (int i = 0; i < valueChildren.getLength(); i++) {
    Node valueChild = valueChildren.item(i);
    if (valueChild instanceof Text) {
	String value = valueChild.getNodeValue();
	String newValue = StringUtils.replace(value, getApplicationContextPathWithClasspath(), "");
	if (newValue.length() < value.length()) {
	    valueChild.setTextContent(newValue);
	    System.out.println(
		    "Removed context entry " + getApplicationContextPathWithClasspath() + " from document.");
	}
    }
}
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:26,代码来源:RemoveToolContextClasspathTask.java

示例5: setServiceDescriptionName

import org.w3c.dom.Node; //导入方法依赖的package包/类
/**
 * Sets the service description name.
 *
 * @param serviceDescriptionFile the service description file
 * @param serviceName the service name
 */
private void setServiceDescriptionName(File serviceDescriptionFile) {
	
	String newServiceName = this.getSymbolicBundleName() + "." + CLASS_LOAD_SERVICE_NAME;
	
	try {
		// --- Open the XML document ------------------
		DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
		DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
		Document doc = docBuilder.parse(serviceDescriptionFile);
		
		// --- Get the XML root/component element -----
		Node component = doc.getFirstChild();
		NamedNodeMap componentAttr = component.getAttributes();
		Node nameAttr = componentAttr.getNamedItem("name");
		nameAttr.setTextContent(newServiceName);
		
		// --- Save document in XML file --------------	
		TransformerFactory transformerFactory = TransformerFactory.newInstance();
		Transformer transformer = transformerFactory.newTransformer();
		DOMSource source = new DOMSource(doc);
		StreamResult result = new StreamResult(serviceDescriptionFile);
		transformer.transform(source, result);
		
	} catch (ParserConfigurationException pcEx) {
		pcEx.printStackTrace();
	} catch (SAXException saxEx) {
		saxEx.printStackTrace();
	} catch (IOException ioEx) {
		ioEx.printStackTrace();
	} catch (TransformerConfigurationException tcEx) {
		tcEx.printStackTrace();
	} catch (TransformerException tEx) {
		tEx.printStackTrace();
	}
	
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:43,代码来源:BundleBuilder.java

示例6: setPropsForCompileFile

import org.w3c.dom.Node; //导入方法依赖的package包/类
/**
 * Description: Editing the xml file for compiling files.
 * @param init path to the xml file
 * @param sourceFile path to the source to be compiled
 */
public static void setPropsForCompileFile(String init, String sourceFile) {
    try {
        File file = new File(sourceFile);
        
        String filepath = init;
        DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
        DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
        Document doc = docBuilder.parse(filepath);
        
        // get project 
        //Node project = doc.getFirstChild();
        Node prop1 = doc.getElementsByTagName("property").item(0);
        Node prop2 = doc.getElementsByTagName("property").item(1);
        Node prop3 = doc.getElementsByTagName("property").item(2);
        
        NamedNodeMap srcAttr = prop1.getAttributes();
        Node srcName = srcAttr.getNamedItem("location");
        srcName.setTextContent( file.getParent());
        
        NamedNodeMap buildAttr = prop2.getAttributes();
        Node buildName = buildAttr.getNamedItem("location");
        buildName.setTextContent( file.getParent());
        
        NamedNodeMap fileAttr = prop3.getAttributes();
        Node fileName = fileAttr.getNamedItem("value");
        fileName.setTextContent( file.getName());
        
        updateBuildFile( filepath, doc);
        
    } catch (Exception ex) {}
}
 
开发者ID:bufferhe4d,项目名称:call-IDE,代码行数:37,代码来源:BuildSys.java

示例7: removeLastCharacter

import org.w3c.dom.Node; //导入方法依赖的package包/类
private void removeLastCharacter(Node node) {
    String value = node.getTextContent();
    if (value.length() > 0) {
        String textContent = value.substring(0, (value.length() - 1));
        node.setTextContent(textContent);
    }
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:8,代码来源:SamlAssertionBreakHandler.java

示例8: convertException

import org.w3c.dom.Node; //导入方法依赖的package包/类
private void convertException(SOAPMessageContext context,
        String newExceptionName) throws SOAPException {
    String saaSApplicationExceptionName = getSaaSApplicationExceptionName();
    NodeList nodeList = context.getMessage().getSOAPBody()
            .getElementsByTagName(PREFIX + newExceptionName);
    if (null == nodeList) {
        return;
    }
    Node node = nodeList.item(0);
    Element newNode = node.getOwnerDocument().createElementNS(
            node.getNamespaceURI(), PREFIX + saaSApplicationExceptionName);

    NodeList list = node.getChildNodes();
    if (null != list) {
        int childrenSize = list.getLength();
        for (int i = 0; i < childrenSize; i++) {
            Node child = list.item(0);
            if (child.getNodeName().equals(PREFIX + MESSAGEKEYTAG)) {
                String content = child.getTextContent().replaceAll(
                        newExceptionName, saaSApplicationExceptionName);
                child.setTextContent(content);
            }
            newNode.appendChild(child);
        }
        node.getParentNode().replaceChild(newNode, node);
    }
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:28,代码来源:ExceptionAdapter.java

示例9: appendLog

import org.w3c.dom.Node; //导入方法依赖的package包/类
private void appendLog(Node parent, String log) {
    if (!log.isEmpty()) {
        Node pre = node("div", "preformatted");
        pre.setTextContent(log);
        parent.appendChild(pre);
    }
}
 
开发者ID:intuit,项目名称:karate,代码行数:8,代码来源:KarateHtmlReporter.java

示例10: setByPath

import org.w3c.dom.Node; //导入方法依赖的package包/类
public static void setByPath(Node doc, String path, String value) {
    Node node = getNodeByPath(doc, path, true);
    if (node.getNodeType() == Node.ATTRIBUTE_NODE) {
        node.setNodeValue(value);
    } else if (node.hasChildNodes() && node.getFirstChild().getNodeType() == Node.TEXT_NODE) {
        node.getFirstChild().setTextContent(value);
    } else if (node.getNodeType() == Node.ELEMENT_NODE) {
        node.setTextContent(value);
    }
}
 
开发者ID:intuit,项目名称:karate,代码行数:11,代码来源:XmlUtils.java

示例11: setNodeValue

import org.w3c.dom.Node; //导入方法依赖的package包/类
public synchronized void setNodeValue(String xpath, Node nodeContext, String value)
{
	Node node = singleNodeFromList(nodeList(xpath, nodeContext));
	if( node != null )
	{
		node.setTextContent(value);
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:9,代码来源:XmlDocument.java

示例12: preProcess

import org.w3c.dom.Node; //导入方法依赖的package包/类
@Override
protected void preProcess(Document doc, Node src, Node dest) throws DocTemplateException {

	NodeList childElements = src.getChildNodes();
	for (int i = 0; i < childElements.getLength(); i++) {
		Node childElement = childElements.item(i);
		Node result = null;
		boolean field = false;
		// OO Field Eigenschaft kann mit "variable-get" oder "variable-set" Knotename behandlen werden.
		if (childElement.getNodeName().endsWith(ODT_BOOKMARK_TAG_SUFFIX)
				|| (field = childElement.getNodeName().endsWith(OO_FIELD_GET_TAG_POSTFIX) || childElement.getNodeName().endsWith(OO_FIELD_SET_TAG_POSTFIX))) {
			String key = "";
			// In Fall des Fields key gleich mit dem "text:name" Eigenschaft
			if (field) {
				key = childElement.getAttributes().getNamedItem(TEXT_NAME).getTextContent();
			} else {
				key = childElement.getAttributes().item(0).getTextContent();
			}
			// mehrere gleiche Textmarken mit ALT-Suffix intern ohne ALT-Suffix anwenden
			int altPos = key.indexOf(ALTERNATE_SUFFIX);
			if (altPos > 0) {
				key = key.substring(0, altPos);
			}
			if (key != null && (key.startsWith(getFieldPrefix()) || key.startsWith(SORTFIELD_PREFIX) || key.startsWith(CONDITION_BEGIN) || key.startsWith(CONDITION_END)
					|| key.startsWith(ITERATION_BEGIN) || key.startsWith(ITERATION_END)) || field) {
				result = doc.createElement(INTERNAL_BOOKMARK_TAG);
				// In Fall des Fields wird ein Feld mit Prefix "FIELD_" generiert. Das bedautet, wir behandlen den
				// OO Field ebenso, als "FIELD_" Bookmark
				result.setTextContent(field ? (getFieldPrefix() + key) : key);
			}
		}
		if (result == null) {
			result = doc.adoptNode(childElement.cloneNode(false));
		}
		dest.appendChild(result);
		preProcess(doc, childElement, result);
	}
}
 
开发者ID:dvbern,项目名称:doctemplate,代码行数:39,代码来源:ODTMergeEngine.java

示例13: toXMLNode

import org.w3c.dom.Node; //导入方法依赖的package包/类
public Node toXMLNode(Document doc, String name) {
	Node node = doc.createElement(name);
	node.setTextContent(start + " | " + end);
	return node;
}
 
开发者ID:DeskChan,项目名称:DeskChan,代码行数:6,代码来源:CharacterRange.java

示例14: appendTo

import org.w3c.dom.Node; //导入方法依赖的package包/类
private void appendTo(Document doc, Node target, String name, String text) {
	Node n = doc.createElement(name);
	n.setTextContent(text);
	target.appendChild(n);
}
 
开发者ID:DeskChan,项目名称:DeskChan,代码行数:6,代码来源:Phrase.java

示例15: preProcess

import org.w3c.dom.Node; //导入方法依赖的package包/类
protected void preProcess(Document doc, Node src, Node dest) throws DocTemplateException {

		NodeList childElements = src.getChildNodes();
		for (int i = 0; i < childElements.getLength(); i++) {
			Node childElement = childElements.item(i);
			Node result = null;
			String nodeName = childElement.getNodeName();
			boolean field = nodeName.toUpperCase().endsWith(XML_FIELD);
			if (NAMESPACE_URI.equals(childElement.getNamespaceURI())) {
				String key = null;
				// In Fall des Fields key gleich mit dem "text:name" Eigenschaft
				if (field) {
					key = getValueOfAttribute(XML_FIELD_PATH, childElement);
					String formatter = getValueOfAttribute(XML_FIELD_FORMATTER, childElement);
					if (!StringUtils.isEmpty(formatter)) {
						String postFix = LdtConstants.FORMAT_SUFFIX + formatter;
						key = key + postFix;
						keyTranslationTable.put(postFix, postFix);
					}
				} else {
					for (String blockElement : BLOCK_MARKERS) {
						if (nodeName.toUpperCase().endsWith(blockElement)) {
							key = blockElement + "_" + childElement.getAttributes().item(0).getTextContent();
							break;
						}
					}
				}
				if (key != null) {
					result = doc.createElement(INTERNAL_BOOKMARK_TAG);
					result.setTextContent(field ? (getFieldPrefix() + key) : key);
					String sort = null;
					if ((sort = getValueOfAttribute(SORT, childElement)) != null) {
						if (!sort.equalsIgnoreCase(ASC) && !sort.equalsIgnoreCase(DESC)) {
							log.warn("Die Sortierung ist falsch: asc oder desc!");
						} else {
							dest.appendChild(result);
							result = doc.createElement(INTERNAL_BOOKMARK_TAG);
							String body = SORT.toUpperCase().concat("_").concat(getPfadOnly(key));
							if (sort.equalsIgnoreCase(DESC)) {
								body = body.concat("_").concat(sort.toUpperCase());
							}
							result.setTextContent(body);
						}
					}
					Node attr = childElement.getAttributes().getNamedItem("attribute");
					if (attr != null) {
						String s = attr.getNodeValue();
						Node srcAttr = src.getAttributes().getNamedItem(s);
						if (srcAttr != null) {
							srcAttr.setNodeValue(INTERNAL_BOOKMARK_XML_ATTR_START + result.getTextContent() + INTERNAL_BOOKMARK_XML_ATTR_END);
							dest.getAttributes().setNamedItem(doc.adoptNode(srcAttr.cloneNode(false)));
							continue;
						}
					}
					if (!field) {
						dest.appendChild(result);
						preProcess(doc, childElement, dest);
						result = doc.createElement(INTERNAL_BOOKMARK_TAG);
						result.setTextContent("END".concat(key));
						dest.appendChild(result);
						continue;
					}
				}
			}
			if (result == null) {
				result = doc.adoptNode(childElement.cloneNode(false));
			}
			dest.appendChild(result);
			preProcess(doc, childElement, result);
		}
	}
 
开发者ID:dvbern,项目名称:doctemplate,代码行数:72,代码来源:XmlMergeEngine.java


注:本文中的org.w3c.dom.Node.setTextContent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。