Example usage for org.w3c.dom Document createTextNode

List of usage examples for org.w3c.dom Document createTextNode

Introduction

In this page you can find the example usage for org.w3c.dom Document createTextNode.

Prototype

public Text createTextNode(String data);

Source Link

Document

Creates a Text node given the specified string.

Usage

From source file:de.codesourcery.jasm16.ide.ProjectConfiguration.java

private Element createElement(String tagName, String value, Document doc) {
    Element result = createElement(tagName, doc);
    result.appendChild(doc.createTextNode(value));
    return result;
}

From source file:edu.lternet.pasta.datapackagemanager.LevelOneEMLFactory.java

private void appendContact(Document doc) {
    Element lnoContact = doc.createElement("contact");
    Element positionName = doc.createElement("positionName");
    positionName.appendChild(doc.createTextNode("Information Manager"));
    Element organizationName = doc.createElement("organizationName");
    organizationName.appendChild(doc.createTextNode("Environmental Data Initiative"));
    Element address = doc.createElement("address");
    Element deliveryPoint1 = doc.createElement("deliveryPoint");
    deliveryPoint1.appendChild(doc.createTextNode("Center for Limnology"));
    Element deliveryPoint2 = doc.createElement("deliveryPoint");
    deliveryPoint2.appendChild(doc.createTextNode("University of Wisconsin"));
    Element city = doc.createElement("city");
    city.appendChild(doc.createTextNode("Madison"));
    Element administrativeArea = doc.createElement("administrativeArea");
    administrativeArea.appendChild(doc.createTextNode("WI"));
    Element postalCode = doc.createElement("postalCode");
    postalCode.appendChild(doc.createTextNode("53706"));
    Element country = doc.createElement("country");
    country.appendChild(doc.createTextNode("USA"));
    address.appendChild(deliveryPoint1);
    address.appendChild(deliveryPoint2);
    address.appendChild(city);/* ww w.j av a  2  s .co  m*/
    address.appendChild(administrativeArea);
    address.appendChild(postalCode);
    address.appendChild(country);
    //Element phone1 = doc.createElement("phone");
    //phone1.setAttribute("phonetype", "voice");
    //phone1.appendChild(doc.createTextNode("505 277-2535"));
    //Element phone2 = doc.createElement("phone");
    //phone2.setAttribute("phonetype", "fax");
    //phone2.appendChild(doc.createTextNode("505 277-2541"));
    Element electronicMailAddress = doc.createElement("electronicMailAddress");
    electronicMailAddress.appendChild(doc.createTextNode("info@environmentaldatainitiative.org"));
    Element onlineUrl = doc.createElement("onlineUrl");
    onlineUrl.appendChild(doc.createTextNode("http://environmentaldatainitiative.org"));
    lnoContact.appendChild(positionName);
    lnoContact.appendChild(organizationName);
    lnoContact.appendChild(address);
    //lnoContact.appendChild(phone1);
    //lnoContact.appendChild(phone2);
    lnoContact.appendChild(electronicMailAddress);
    lnoContact.appendChild(onlineUrl);
    NodeList contacts = getContacts(doc);
    Node datasetNode = getDatasetNode(doc);
    datasetNode.insertBefore(lnoContact, contacts.item(0));
}

From source file:com.idega.slide.util.WebdavLocalResource.java

private Element getEmptyElement() {
    if (emptyElement == null) {
        Document doc = XmlUtil.getXMLBuilder().newDocument();
        emptyElement = doc.createElementNS("DAV:", "resourcetype");
        emptyElement.appendChild(doc.createTextNode(CoreConstants.EMPTY));
    }//from   w w  w  .  j a  va  2  s  . c o  m
    return emptyElement;
}

From source file:uk.co.markfrimston.tasktree.TaskTree.java

protected void makeConfigEl(Document doc, Node parent, String name, String description, Object value) {
    parent.appendChild(doc.createTextNode("\n\t"));
    parent.appendChild(doc.createComment(description));
    parent.appendChild(doc.createTextNode("\n\t"));
    Element elParam = doc.createElement(name);
    if (value != null) {
        elParam.appendChild(doc.createTextNode(String.valueOf(value)));
    }/*from  ww  w  .  ja v a 2s.  co m*/
    parent.appendChild(elParam);
    parent.appendChild(doc.createTextNode("\n"));
}

From source file:com.commander4j.messages.OutgoingDespatchConfirmation.java

public Element addElement(Document doc, String name, String value) {
    Element temp = (Element) doc.createElement(name);
    Text temp_value = doc.createTextNode(value);
    temp.appendChild(temp_value);//  w ww .  j a  va 2 s.  co  m
    return temp;
}

From source file:de.crowdcode.movmvn.plugin.general.GeneralPlugin.java

private void createPomDependencies(Document doc, Element rootElement) {
    Element dependencies = doc.createElement("dependencies");
    rootElement.appendChild(dependencies);
    Element dependency = doc.createElement("dependency");
    dependencies.appendChild(dependency);

    createPomGroupArtifactVersion(doc, dependency, "junit", "junit", "4.10");
    Element scope = doc.createElement("scope");
    scope.appendChild(doc.createTextNode("test"));
    dependency.appendChild(scope);//  w  w  w . j  a  v a2  s.  c o m
}

From source file:de.ingrid.interfaces.csw.server.cswt.impl.GenericServerCSWT.java

private Document createErrorResponse(CSWTransactionResult result) throws ParserConfigurationException {
    DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
    docFactory.setNamespaceAware(true);//ww w  . j a  v a 2  s. com
    DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
    DOMImplementation domImpl = docBuilder.getDOMImplementation();
    Document doc = domImpl.createDocument(RESPONSE_NAMESPACE, "ows:ExceptionReport", null);

    // create summary
    Element exception = doc.createElementNS(RESPONSE_NAMESPACE, "ows:Exception");
    exception.setAttribute("exceptionCode", "NoApplicableCode");
    doc.getDocumentElement().appendChild(exception);

    exception.appendChild(doc.createElementNS(RESPONSE_NAMESPACE, "ows:ExceptionText"))
            .appendChild(doc.createTextNode("Cannot process transaction: " + result.getErrorMessage()));

    return doc;

}

From source file:fr.ortolang.diffusion.seo.SeoServiceBean.java

private Element buildSiteMapEntry(String loc, String lastmod, ChangeFrequency changefreq, String priority,
        Document doc) throws SeoServiceException {
    Element url = doc.createElementNS(SITEMAP_NS_URI, "url");

    if (loc == null || loc.length() == 0) {
        throw new SeoServiceException("Cannot generate site map entry: 'loc' is mandatory");
    }/*w  w  w. j  a  v a2 s .  c  om*/
    Element locElement = doc.createElementNS(SITEMAP_NS_URI, "loc");
    locElement.appendChild(doc.createTextNode(loc));
    url.appendChild(locElement);

    if (lastmod != null) {
        Element lastmodElement = doc.createElementNS(SITEMAP_NS_URI, "lastmod");
        lastmodElement.appendChild(doc.createTextNode(lastmod));
        url.appendChild(lastmodElement);
    }

    if (changefreq != null) {
        Element changefreqElement = doc.createElementNS(SITEMAP_NS_URI, "changefreq");
        changefreqElement.appendChild(doc.createTextNode(changefreq.name().toLowerCase()));
        url.appendChild(changefreqElement);
    }

    if (priority != null) {
        Element priorityElement = doc.createElementNS(SITEMAP_NS_URI, "priority");
        priorityElement.appendChild(doc.createTextNode(priority));
        url.appendChild(priorityElement);
    }
    return url;
}

From source file:net.sourceforge.eclipsetrader.core.internal.TradingSystemRepository.java

private void saveSystem(TradingSystem system, Document document, Element root) {
    Element element = document.createElement("system"); //$NON-NLS-1$
    element.setAttribute("id", String.valueOf(system.getId())); //$NON-NLS-1$
    element.setAttribute("pluginId", system.getPluginId()); //$NON-NLS-1$
    root.appendChild(element);/*from  w  w w  .  ja  va  2 s .c o m*/

    Element node = document.createElement("security"); //$NON-NLS-1$
    node.appendChild(document.createTextNode(String.valueOf(system.getSecurity().getId())));
    element.appendChild(node);
    node = document.createElement("account"); //$NON-NLS-1$
    node.appendChild(document.createTextNode(String.valueOf(system.getAccount().getId())));
    element.appendChild(node);
    node = document.createElement("max_exposure"); //$NON-NLS-1$
    node.appendChild(document.createTextNode(String.valueOf(system.getMaxExposure())));
    element.appendChild(node);
    node = document.createElement("min_amount"); //$NON-NLS-1$
    node.appendChild(document.createTextNode(String.valueOf(system.getMinAmount())));
    element.appendChild(node);
    node = document.createElement("max_amount"); //$NON-NLS-1$
    node.appendChild(document.createTextNode(String.valueOf(system.getMaxAmount())));
    element.appendChild(node);
    if (system.getDate() != null) {
        node = document.createElement("date"); //$NON-NLS-1$
        node.appendChild(document.createTextNode(dateTimeFormat.format(system.getDate())));
        element.appendChild(node);
    }
    node = document.createElement("signal"); //$NON-NLS-1$
    node.appendChild(document.createTextNode(String.valueOf(system.getSignal())));
    element.appendChild(node);

    for (Iterator paramIter = system.getParameters().keySet().iterator(); paramIter.hasNext();) {
        String key = (String) paramIter.next();

        node = document.createElement("param"); //$NON-NLS-1$
        node.setAttribute("key", key); //$NON-NLS-1$
        node.appendChild(document.createTextNode((String) system.getParameters().get(key)));
        element.appendChild(node);
    }
}

From source file:com.adaptris.util.XmlUtils.java

/**
 * Method which modifies the value of the Node returned by the XPath query
 * specified, relative to the provided parent node.
 *
 * @param xp the XPath which will return the Node to be updated
 * @param v the new value to set the node to
 * @param root the root node to apply the XPath to
 * @throws Exception on error.//from w ww.  j  a v a 2 s.  c o  m
 */
public void setNodeValue(String xp, String v, Node root) throws Exception {
    Node n = xpath.selectSingleNode(root, xp);

    if (n == null) {
        n = createNode(xp);
    }
    try {
        setNodeValue(v, n);
    } catch (NullPointerException ne) {
        // Node has no children!
        Document d = n.getOwnerDocument();
        Text t = d.createTextNode(v);
        n.appendChild(t);
    }

}