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


Java Node.appendChild方法代码示例

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


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

示例1: writePrimitiveAttribute

import org.w3c.dom.Node; //导入方法依赖的package包/类
/**
 * Writes the given value as an attribute of the given node.
 */
protected void writePrimitiveAttribute(mxCodec enc, Object obj,
		String attr, Object value, Node node)
{
	if (attr == null || obj instanceof Map)
	{
		Node child = enc.document.createElement("add");

		if (attr != null)
		{
			mxCodec.setAttribute(child, "as", attr);
		}

		mxCodec.setAttribute(child, "value", value);
		node.appendChild(child);
	}
	else
	{
		mxCodec.setAttribute(node, attr, value);
	}
}
 
开发者ID:GDSRS,项目名称:TrabalhoFinalEDA2,代码行数:24,代码来源:mxObjectCodec.java

示例2: marshal

import org.w3c.dom.Node; //导入方法依赖的package包/类
public void marshal(Node parent, String dsPrefix, DOMCryptoContext context)
    throws MarshalException
{
    Document ownerDoc = DOMUtils.getOwnerDocument(parent);

    Element isElem = DOMUtils.createElement(ownerDoc, "X509IssuerSerial",
                                            XMLSignature.XMLNS, dsPrefix);
    Element inElem = DOMUtils.createElement(ownerDoc, "X509IssuerName",
                                            XMLSignature.XMLNS, dsPrefix);
    Element snElem = DOMUtils.createElement(ownerDoc, "X509SerialNumber",
                                            XMLSignature.XMLNS, dsPrefix);
    inElem.appendChild(ownerDoc.createTextNode(issuerName));
    snElem.appendChild(ownerDoc.createTextNode(serialNumber.toString()));
    isElem.appendChild(inElem);
    isElem.appendChild(snElem);
    parent.appendChild(isElem);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:DOMX509IssuerSerial.java

示例3: migrateBillingResultXml

import org.w3c.dom.Node; //导入方法依赖的package包/类
protected String migrateBillingResultXml(String billingXml)
        throws ParserConfigurationException, SAXException, IOException,
        TransformerException, XPathExpressionException {
    Document document = XMLConverter.convertToDocument(billingXml, false);
    NodeList nodeList = XMLConverter.getNodeListByXPath(document,
            XPATH_GATHEREDEVENTS);
    for (int i = 0; i < nodeList.getLength(); i++) {
        Node gatheredEvents = nodeList.item(i);
        if (!istotalEventCostsAlreadyPresent(gatheredEvents)
                && gatheredEvents.getChildNodes().getLength() > 0) {
            Element totalCosts = createNodeTotalEventCosts(gatheredEvents);
            gatheredEvents.appendChild(totalCosts);
        }
    }
    return XMLConverter.convertToString(document, false);
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:17,代码来源:MigrationBillingResultGatheredEvents.java

示例4: appendChildren

import org.w3c.dom.Node; //导入方法依赖的package包/类
/**
 * Appends the child nodes of another propbag into the node located by
 * szNodeName
 * 
 * @param szNodeName The path to insert into
 * @param xml The propbag that we want the children of
 */
public void appendChildren(final String szNodeName, final PropBagEx xml)
{
	checkNotAttribute(szNodeName);

	ensureRoot();
	xml.ensureRoot();
	Node oNode = getNodeHelper(szNodeName, false, false);
	if( oNode == null )
	{
		createNode(szNodeName, BLANK);
		oNode = getNodeHelper(szNodeName, false, false);
	}

	final Document doc = oNode.getOwnerDocument();
	Node child = xml.m_elRoot.getFirstChild();
	while( child != null )
	{
		oNode.appendChild(importNode(doc, child, true));
		child = child.getNextSibling();
	}

	// we might have pushed two text nodes together, normalise it
	oNode.normalize();
}
 
开发者ID:equella,项目名称:Equella,代码行数:32,代码来源:PropBagEx.java

示例5: marshal

import org.w3c.dom.Node; //导入方法依赖的package包/类
public void marshal(Node parent, String dsPrefix, DOMCryptoContext context)
    throws MarshalException
{
    Document ownerDoc = DOMUtils.getOwnerDocument(parent);
    // prepend namespace prefix, if necessary
    Element knElem = DOMUtils.createElement(ownerDoc, "KeyName",
                                            XMLSignature.XMLNS, dsPrefix);
    knElem.appendChild(ownerDoc.createTextNode(name));
    parent.appendChild(knElem);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:11,代码来源:DOMKeyName.java

示例6: startElement

import org.w3c.dom.Node; //导入方法依赖的package包/类
/**
 * Adds a new child {@link org.w3c.dom.Element Element} to the current
 * node.
 * 
 * @param namespaceURI the namespace URI
 * @param localName the local name
 * @param qName the qualified (prefixed) name
 * @param atts the list of attributes
 * @throws SAXException if the DOM implementation throws an exception
 */
@Override
public void startElement(String namespaceURI, String localName,
                         String qName, Attributes atts)
    throws SAXException {

    try {
        Node previousTop = top;
        if ((localName == null) || (localName.length() == 0)) { 
            top = doc.createElement(qName);
        } else {
            top = doc.createElementNS(namespaceURI, localName);
        }
        for (int i = 0; i < atts.getLength(); i++) {
            Attr attr = null;
            if ((atts.getLocalName(i) == null) ||
                (atts.getLocalName(i).length() == 0)) {
                attr = doc.createAttribute(atts.getQName(i));
                attr.setNodeValue(atts.getValue(i));
                ((Element)top).setAttributeNode(attr);
            } else {
                attr = doc.createAttributeNS(atts.getURI(i),
                                             atts.getLocalName(i));
                attr.setNodeValue(atts.getValue(i));
                ((Element)top).setAttributeNodeNS(attr);
            }
        }
        previousTop.appendChild(top);
        depth++;
    } catch (DOMException e) {
        throw new SAXException(e.getMessage(), e);
    }

}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:44,代码来源:NodeCreateRule.java

示例7: marshalSKI

import org.w3c.dom.Node; //导入方法依赖的package包/类
private void marshalSKI(byte[] skid, Node parent, Document doc,
                        String dsPrefix)
{
    Element skidElem = DOMUtils.createElement(doc, "X509SKI",
                                              XMLSignature.XMLNS, dsPrefix);
    skidElem.appendChild(doc.createTextNode(Base64.encode(skid)));
    parent.appendChild(skidElem);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:9,代码来源:DOMX509Data.java

示例8: marshal

import org.w3c.dom.Node; //导入方法依赖的package包/类
public void marshal(Node parent, String dsPrefix,
                    DOMCryptoContext context)
    throws MarshalException
{
    // create SignatureValue element
    sigValueElem = DOMUtils.createElement(ownerDoc, "SignatureValue",
                                          XMLSignature.XMLNS, dsPrefix);
    if (valueBase64 != null) {
        sigValueElem.appendChild(ownerDoc.createTextNode(valueBase64));
    }

    // append Id attribute, if specified
    DOMUtils.setAttributeID(sigValueElem, "Id", id);
    parent.appendChild(sigValueElem);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:16,代码来源:DOMXMLSignature.java

示例9: makeText

import org.w3c.dom.Node; //导入方法依赖的package包/类
private void makeText(Node parent, int pos) {
    if (pos <= this.pos) {
        return;
    }
    Text text = document.createTextNode(contents.substring(this.pos, pos));
    parent.appendChild(text);
    this.pos = pos;
}
 
开发者ID:Bibliome,项目名称:alvisnlp,代码行数:9,代码来源:XMLWriter2ForINIST.java

示例10: marshalCert

import org.w3c.dom.Node; //导入方法依赖的package包/类
private void marshalCert(X509Certificate cert, Node parent, Document doc,
                         String dsPrefix)
    throws MarshalException
{
    Element certElem = DOMUtils.createElement(doc, "X509Certificate",
                                              XMLSignature.XMLNS, dsPrefix);
    try {
        certElem.appendChild(doc.createTextNode
                             (Base64.encode(cert.getEncoded())));
    } catch (CertificateEncodingException e) {
        throw new MarshalException("Error encoding X509Certificate", e);
    }
    parent.appendChild(certElem);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:15,代码来源:DOMX509Data.java

示例11: marshal

import org.w3c.dom.Node; //导入方法依赖的package包/类
public void marshal(Node parent, String dsPrefix, DOMCryptoContext context)
    throws MarshalException
{
    Document ownerDoc = DOMUtils.getOwnerDocument(parent);
    Element rmElem = DOMUtils.createElement(ownerDoc, "RetrievalMethod",
                                            XMLSignature.XMLNS, dsPrefix);

    // add URI and Type attributes
    DOMUtils.setAttribute(rmElem, "URI", uri);
    DOMUtils.setAttribute(rmElem, "Type", type);

    // add Transforms elements
    if (!transforms.isEmpty()) {
        Element transformsElem = DOMUtils.createElement(ownerDoc,
                                                        "Transforms",
                                                        XMLSignature.XMLNS,
                                                        dsPrefix);
        rmElem.appendChild(transformsElem);
        for (Transform transform : transforms) {
            ((DOMTransform)transform).marshal(transformsElem,
                                               dsPrefix, context);
        }
    }

    parent.appendChild(rmElem);

    // save here node
    here = rmElem.getAttributeNodeNS(null, "URI");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:30,代码来源:DOMRetrievalMethod.java

示例12: writeForkSection

import org.w3c.dom.Node; //导入方法依赖的package包/类
/**
 * Writes a Fork output section <br>
 * Author: Bertoli Marco
 *
 * @param doc
 *            document root
 * @param node
 *            node where created section should be appended
 * @param model
 *            data structure
 * @param stationKey
 *            search's key for fork
 */
private static void writeForkSection(Document doc, Node node,
		CommonModel model, Object stationKey) {
	Element fork = doc.createElement(XML_E_STATION_SECTION);
	fork.setAttribute(XML_A_STATION_SECTION_CLASSNAME, CLASSNAME_FORK);
	node.appendChild(fork);
	// Creates jobsPerLink parameter
	XMLParameter jobsPerLink = new XMLParameter("jobsPerLink", model
			.getStationNumberOfServers(stationKey).getClass().getName(),
			null, model.getStationNumberOfServers(stationKey).toString(),
			false);
	// Creates block parameter
	XMLParameter block = new XMLParameter("block", model
			.getForkBlock(stationKey).getClass().getName(), null, model
			.getForkBlock(stationKey).toString(), false);
	// ...and adds them as fork's children
	XMLParameter isSim = new XMLParameter("isSimplifiedFork", model
			.getIsSimplifiedFork(stationKey).getClass().getName(), null,
			model.getIsSimplifiedFork(stationKey).toString(), false);
	jobsPerLink.appendParameterElement(doc, fork);
	block.appendParameterElement(doc, fork);
	isSim.appendParameterElement(doc, fork);

	Vector<Object> classes = model.getClassKeys();
	XMLParameter[] forkStrats = new XMLParameter[classes.size()];
	Object currentClass;
	for (int i = 0; i < forkStrats.length; i++) {
		currentClass = classes.get(i);
		forkStrats[i] = ForkStrategyWriter
				.getForkStrategyParameter((ForkStrategy) model
						.getForkStrategy(stationKey, currentClass),
						model, currentClass, stationKey);
	}
	XMLParameter globalFork = new XMLParameter("ForkStrategy",
			strategiesClasspathBase + "ForkStrategy", null, forkStrats,
			false);
	globalFork.appendParameterElement(doc, fork);
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:51,代码来源:XMLWriter.java

示例13: updateField

import org.w3c.dom.Node; //导入方法依赖的package包/类
@Override
public void updateField(ObjectName oname, String name, Object value) {
	if (loading)
		return;
	// nothing by default
	// log.info( "XXX UpdateField " + oname + " " + name + " " + value);
	Node n = object2Node.get(oname);
	if (n == null) {
		log.info("Node not found " + oname);
		return;
	}
	Node attNode = DomUtil.findChildWithAtt(n, "attribute", "name", name);
	if (attNode == null) {
		// found no existing attribute with this name
		attNode = n.getOwnerDocument().createElement("attribute");
		DomUtil.setAttribute(attNode, "name", name);
		n.appendChild(attNode);
	}
	String oldValue = DomUtil.getAttribute(attNode, "value");
	if (oldValue != null) {
		// we'll convert all values to text content
		DomUtil.removeAttribute(attNode, "value");
	}
	DomUtil.setText(attNode, value.toString());

	// store();
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:28,代码来源:MbeansSource.java

示例14: processingInstruction

import org.w3c.dom.Node; //导入方法依赖的package包/类
/**
 * adds processing instruction node to DOM.
 */
public void processingInstruction(String target, String data) {
  final Node last = (Node) _nodeStk.peek();
  ProcessingInstruction pi = _document.createProcessingInstruction(target, data);
  if (pi != null)
    last.appendChild(pi);
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:10,代码来源:Sax2Dom.java

示例15: createDocWithSequentTextNodes

import org.w3c.dom.Node; //导入方法依赖的package包/类
private Document createDocWithSequentTextNodes() throws Exception {
    DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
    Document doc = db.newDocument();
    Node root = doc.createElement("root");
    doc.appendChild(root);
    root.appendChild(doc.createTextNode("\n"));
    root.appendChild(doc.createTextNode("\n"));
    root.appendChild(doc.createTextNode("\n"));
    root.appendChild(doc.createTextNode(" "));
    root.appendChild(doc.createTextNode("t"));
    root.appendChild(doc.createTextNode("\n"));
    root.appendChild(doc.createTextNode("t"));
    root.appendChild(doc.createTextNode("   "));
    Node child1 = doc.createElement("child1");
    root.appendChild(child1);
    child1.appendChild(doc.createTextNode(" "));
    child1.appendChild(doc.createTextNode("\n"));
    root.appendChild(doc.createTextNode("t"));
    Node child2 = doc.createElement("child2");
    root.appendChild(child2);
    child2.appendChild(doc.createTextNode(" "));
    root.appendChild(doc.createTextNode(" "));
    Node child3 = doc.createElement("child3");
    root.appendChild(child3);
    child3.appendChild(doc.createTextNode(" "));
    root.appendChild(doc.createTextNode(" "));
    Node child4 = doc.createElement("child4");
    root.appendChild(child4);
    child4.appendChild(doc.createTextNode(" "));

    root.appendChild(doc.createTextNode(" "));
    Node child5 = doc.createElement("child5");
    root.appendChild(child5);
    child5.appendChild(doc.createTextNode("t"));

    Node child51 = doc.createElement("child51");
    child5.appendChild(child51);
    child51.appendChild(doc.createTextNode(" "));
    Node child511 = doc.createElement("child511");
    child51.appendChild(child511);
    child511.appendChild(doc.createTextNode("t"));
    child51.appendChild(doc.createTextNode(" "));
    child5.appendChild(doc.createTextNode("t"));

    root.appendChild(doc.createTextNode(" "));
    root.appendChild(doc.createComment(" test comment "));
    root.appendChild(doc.createTextNode(" \n"));
    root.appendChild(doc.createComment(" "));
    root.appendChild(doc.createTextNode("\n"));
    root.appendChild(doc.createProcessingInstruction("target1", "test"));
    root.appendChild(doc.createTextNode(" "));
    root.appendChild(doc.createTextNode(" "));
    return doc;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:55,代码来源:PrettyPrintTest.java


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