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


Java Element.appendChild方法代码示例

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


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

示例1: mediaListToDocument

import org.w3c.dom.Element; //导入方法依赖的package包/类
public static Document mediaListToDocument(List<Media> list) {
    Document dom = null;
    // instance of a DocumentBuilderFactory
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    try {
        // use factory to get an instance of document builder
        DocumentBuilder db = dbf.newDocumentBuilder();
        // create instance of DOM
        dom = db.newDocument();

        // create the root element
        Element rootEle = dom.createElement(root);

        for (Media m : list)
            rootEle.appendChild(mediaToElement(m,dom));

        dom.appendChild(rootEle);

    } catch (ParserConfigurationException pce) {
        System.out.println("UsersXML: Error trying to instantiate DocumentBuilder " + pce);
    }
    
    return dom;
}
 
开发者ID:NonlinearFruit,项目名称:Retrospector-Android,代码行数:25,代码来源:XmlService.java

示例2: engineAddContextToElement

import org.w3c.dom.Element; //导入方法依赖的package包/类
/**
 * Method engineAddContextToElement
 *
 * @param element
 */
public void engineAddContextToElement(Element element) {
    if (element == null) {
        throw new IllegalArgumentException("null element");
    }

    if (this.HMACOutputLengthSet) {
        Document doc = element.getOwnerDocument();
        Element HMElem =
            XMLUtils.createElementInSignatureSpace(doc, Constants._TAG_HMACOUTPUTLENGTH);
        Text HMText =
            doc.createTextNode(Integer.valueOf(this.HMACOutputLength).toString());

        HMElem.appendChild(HMText);
        XMLUtils.addReturnToElement(element);
        element.appendChild(HMElem);
        XMLUtils.addReturnToElement(element);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:24,代码来源:IntegrityHmac.java

示例3: marshal

import org.w3c.dom.Element; //导入方法依赖的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:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:18,代码来源:DOMX509IssuerSerial.java

示例4: addTextElement

import org.w3c.dom.Element; //导入方法依赖的package包/类
/**
 * Method addTextElement
 *
 * @param text
 * @param localname
 */
public void addTextElement(String text, String localname) {
    Element e = XMLUtils.createElementInSignatureSpace(this.doc, localname);
    Text t = this.doc.createTextNode(text);

    e.appendChild(t);
    this.constructionElement.appendChild(e);
    XMLUtils.addReturnToElement(this.constructionElement);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:15,代码来源:ElementProxy.java

示例5: serialize

import org.w3c.dom.Element; //导入方法依赖的package包/类
public Element serialize(Document document, DBModel model) {
    Element rootElement = document.createElement(ROOT_ELEMENT_TAG_NAME);
    rootElement.appendChild(createElementWithContent(document, ELEMENT_NAME_TAG_NAME, model.getName()));
    rootElement.appendChild(createElementWithContent(document, ELEMENT_HOST_TAG_NAME, model.getHost()));
    rootElement.appendChild(createElementWithContent(document, ELEMENT_PORT_TAG_NAME, model.getPort()));
    rootElement.appendChild(createElementWithContent(document, ELEMENT_DATABASE_NAME_TAG_NAME, model.getDatabaseName()));
    rootElement.appendChild(createElementWithContent(document, ELEMENT_USER_TAG_NAME, model.getUser()));
    rootElement.appendChild(createElementWithContent(document, ELEMENT_PASSWORD_TAG_NAME, model.getPassword()));
    rootElement.appendChild(createElementWithContent(document, ELEMENT_ENABLED_TAG_NAME, String.valueOf(model.isEnabled())));
    return rootElement;
}
 
开发者ID:technology16,项目名称:pgsqlblocks,代码行数:12,代码来源:DBModelSerializer.java

示例6: characters

import org.w3c.dom.Element; //导入方法依赖的package包/类
public void characters(XMLString text, Augmentations augs)
        throws XNIException {
    if (!fIgnoreChars) {
        final Element currentElement = (Element) fDOMValidatorHelper.getCurrentElement();
        currentElement.appendChild(fDocument.createTextNode(text.toString()));
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:8,代码来源:DOMResultAugmentor.java

示例7: getXML

import org.w3c.dom.Element; //导入方法依赖的package包/类
Element getXML(Document placement) {
    Element parameter = placement.createElement("parameter");
    parameter.setAttribute("name", name);
    parameter.setAttribute("class", type);
    Element defaultValueExpression = placement.createElement("defaultValueExpression");
    defaultValueExpression.appendChild(ReportUtil.formatTextExpression(defaultExpression, placement));
    parameter.appendChild(defaultValueExpression);
    return parameter;
}
 
开发者ID:NVIvanov,项目名称:jrbuilder,代码行数:10,代码来源:Parameter.java

示例8: operatorExported

import org.w3c.dom.Element; //导入方法依赖的package包/类
/**
 * Adds the position and size of the operator to the XML element.
 */
@Override
public void operatorExported(final Operator op, final Element opElement) {
	// add operator location and size
	Rectangle2D bounds = lookupOperatorRectangle(op);
	if (bounds != null) {
		opElement.setAttribute(XML_ATTRIBUTE_X_POSITION, "" + (int) bounds.getX());
		opElement.setAttribute(XML_ATTRIBUTE_Y_POSITION, "" + (int) bounds.getY());
		opElement.setAttribute(XML_ATTRIBUTE_WIDTH, "" + (int) bounds.getWidth());
		opElement.setAttribute(XML_ATTRIBUTE_HEIGHT, "" + (int) bounds.getHeight());
	}

	// add workflow annotations
	WorkflowAnnotations annotations = lookupOperatorAnnotations(op);
	if (annotations != null) {
		for (WorkflowAnnotation annotation : annotations.getAnnotationsDrawOrder()) {
			Element annotationElement = opElement.getOwnerDocument().createElement(XML_TAG_ANNOTATION);

			Text commentNode = opElement.getOwnerDocument().createTextNode(annotation.getComment());
			bounds = annotation.getLocation().getBounds();
			annotationElement.setAttribute(XML_ATTRIBUTE_WIDTH, "" + (int) bounds.getWidth());
			annotationElement.setAttribute(XML_ATTRIBUTE_COLOR, annotation.getStyle().getAnnotationColor().getKey());
			annotationElement.setAttribute(XML_ATTRIBUTE_ALIGNMENT, annotation.getStyle().getAnnotationAlignment()
					.getKey());
			annotationElement.setAttribute(XML_ATTRIBUTE_COLORED, String.valueOf(annotation.wasColored()));
			annotationElement.appendChild(commentNode);

			opElement.appendChild(annotationElement);
		}
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:34,代码来源:GUIProcessXMLFilter.java

示例9: createStepNodeValue

import org.w3c.dom.Element; //导入方法依赖的package包/类
@Override
protected void createStepNodeValue(Document doc, Element stepNode) throws EngineException {
	String nodeValue = getSequence().context.getAuthenticatedUser();
	if (nodeValue != null && nodeValue.length() > 0) {
		Node text = doc.createTextNode(nodeValue);
		stepNode.appendChild(text);
	}
}
 
开发者ID:convertigo,项目名称:convertigo-engine,代码行数:9,代码来源:RemoveAuthenticatedUserStep.java

示例10: fromToolbarData

import org.w3c.dom.Element; //导入方法依赖的package包/类
Element fromToolbarData() {
	Element elt = doc.createElement("toolbar");
	ToolbarData toolbar = file.getOptions().getToolbarData();
	for (Tool tool : toolbar.getContents()) {
		if (tool == null) {
			elt.appendChild(doc.createElement("sep"));
		} else {
			elt.appendChild(fromTool(tool));
		}
	}
	return elt;
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:13,代码来源:XmlWriter.java

示例11: marshall

import org.w3c.dom.Element; //导入方法依赖的package包/类
@Override
public Node marshall(Document document) {
    Element signatureInfo = createThisElement(document);
    Element canonicalizationMethod = createElement(document, CANONICALIZATION_METHOD);
    Element redactableSignatureAlgorithm = createElement(document, REDACTABLE_SIGNATURE_ALGORITHM);

    canonicalizationMethod.setAttribute("Algorithm", this.canonicalizationMethod);
    redactableSignatureAlgorithm.setAttribute("Algorithm", this.redactableSignatureAlgorithm);

    signatureInfo.appendChild(canonicalizationMethod);
    signatureInfo.appendChild(redactableSignatureAlgorithm);

    return signatureInfo;
}
 
开发者ID:woefe,项目名称:xmlrss,代码行数:15,代码来源:SignatureInfo.java

示例12: createNodeNode

import org.w3c.dom.Element; //导入方法依赖的package包/类
/**
* Create Node to XML from Node Graph
*/
private org.w3c.dom.Node createNodeNode(int i) {
	Element graphNode = getDocument().createElement("node");

	Element xmlProperties = getDocument().createElement("properties");

	ComponentProperties prop = (xmlGraph.getNode(i)).getProperties();

	// Position
	Position pos = (Position) prop.getPropertyByName("Position");
	xmlProperties.appendChild(createNodeProperty(pos));

	// Label
	Label lbl = (Label) prop.getPropertyByName("Label");
	xmlProperties.appendChild(createNodeProperty(lbl));

	// ID
	ID id =(ID) prop.getPropertyByName("ID");
	xmlProperties.appendChild(createNodeProperty(id));

	// Component Color
	ComponentColor cc = (ComponentColor) prop.getPropertyByName("ComponentColor");
	xmlProperties.appendChild(createNodeProperty(cc));

	graphNode.appendChild(xmlProperties);
	return (graphNode);
}
 
开发者ID:guilhebl,项目名称:routerapp,代码行数:30,代码来源:XMLGraphDAO.java

示例13: appendParameterElement

import org.w3c.dom.Element; //导入方法依赖的package包/类
public void appendParameterElement(Document doc, Element scope) {
	//creating inner element containing queue length
	Element parameter = doc.createElement(isSubParameter ? XML_E_SUBPARAMETER : XML_E_PARAMETER);
	if (parameterClasspath != null) {
		parameter.setAttribute(XML_A_PARAMETER_CLASSPATH, parameterClasspath);
	}
	if (parameterName != null) {
		parameter.setAttribute(XML_A_PARAMETER_NAME, parameterName);
	}
	if (parameterArray != null && "true".equals(parameterArray)) {
		parameter.setAttribute(XML_A_PARAMETER_ARRAY, parameterArray);
	}

	//adding element refclass for this parameter
	if (parameterRefClass != null) {
		Element refclass = doc.createElement(XML_E_PARAMETER_REFCLASS);
		refclass.appendChild(doc.createTextNode(parameterRefClass));
		scope.appendChild(refclass);
	}
	//adding element value of parameter
	if (parameterValue != null) {
		Element value = doc.createElement(XML_E_PARAMETER_VALUE);
		value.appendChild(doc.createTextNode(parameterValue));
		parameter.appendChild(value);
	}
	if (parameters != null) {
		for (XMLParameter parameter2 : parameters) {
			if (parameter2 != null) {
				parameter2.appendParameterElement(doc, parameter);
			}
		}
	}
	scope.appendChild(parameter);
}
 
开发者ID:HOMlab,项目名称:QN-ACTR-Release,代码行数:35,代码来源:XMLWriter.java

示例14: createTextElement

import org.w3c.dom.Element; //导入方法依赖的package包/类
public static Element createTextElement(final Document document, final String qName, final String content, final Optional<String> namespaceURI) {
    Element typeElement = createElement(document, qName, namespaceURI);
    typeElement.appendChild(document.createTextNode(content));
    return typeElement;
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:6,代码来源:XmlUtil.java

示例15: saveToXML

import org.w3c.dom.Element; //导入方法依赖的package包/类
public static void saveToXML(String oXMLFile) {
    String[] strsPath = oXMLFile.split("/");
    String strsProject = strsPath[strsPath.length-1];

    String[] strs = strsProject.split("\\."); // or "[.]"
    String projectName = strs[0];
    try {
        DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
        DocumentBuilder docBuilder = docFactory.newDocumentBuilder();


        // root
        Document doc = docBuilder.newDocument();
        Element rootElement = doc.createElement("project");
        rootElement.setAttribute("name", projectName);

        doc.appendChild(rootElement);

        Element subRootElement = doc.createElement("tokens");
        rootElement.appendChild(subRootElement);

        for (int i = 0; i < tokenLab.size(); i++) {
            Element tokenElement = doc.createElement("token");
            // number
            Element numberElement = doc.createElement("number");
            numberElement.appendChild(doc.createTextNode(String.valueOf(tokenLab.get(i).number)));
            tokenElement.appendChild(numberElement);

            // line
            Element lineElement = doc.createElement("line");
            lineElement.appendChild(doc.createTextNode(String.valueOf(tokenLab.get(i).line)));
            tokenElement.appendChild(lineElement);

            // value
            Element valueElement = doc.createElement("value");
            valueElement.appendChild(doc.createTextNode(tokenLab.get(i).value));
            tokenElement.appendChild(valueElement);

            // type
            Element typeElement = doc.createElement("type");
            typeElement.appendChild(doc.createTextNode(typeIntToString(tokenLab.get(i).type)));
            tokenElement.appendChild(typeElement);

            // valid
            Element validElement = doc.createElement("valid");
            validElement.appendChild(doc.createTextNode(String.valueOf(tokenLab.get(i).isValid)));
            tokenElement.appendChild(validElement);

            subRootElement.appendChild(tokenElement);
        }

        TransformerFactory transformerFactory = TransformerFactory.newInstance();
        Transformer transformer = transformerFactory.newTransformer();
        DOMSource source = new DOMSource(doc);
        StreamResult result = new StreamResult(new File(oXMLFile));

        transformer.setOutputProperty(OutputKeys.INDENT, "yes");
        transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");

        transformer.transform(source, result);

        System.out.println("File saved!");
    } catch (Exception e) {
        e.printStackTrace();
    }

}
 
开发者ID:hologerry,项目名称:Compiler,代码行数:68,代码来源:GScanner.java


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