Example usage for org.w3c.dom Element setTextContent

List of usage examples for org.w3c.dom Element setTextContent

Introduction

In this page you can find the example usage for org.w3c.dom Element setTextContent.

Prototype

public void setTextContent(String textContent) throws DOMException;

Source Link

Document

This attribute returns the text content of this node and its descendants.

Usage

From source file:org.openmrs.module.xforms.aop.XformsProviderAdvisor.java

/**
 * Adds a new provider node to the xforms docuement.
 * /*  w  w w.j  av a  2 s.com*/
 * @param doc the xforms document.
 * @param providerSelect1Element the select1 element to add the provider node.
 * @param user the provider to add.
 * @param personId the person id represented by the provider.
 */
private void addNewProviderNode(Document doc, Element providerSelect1Element, User user, Integer personId) {
    Element itemNode = doc.createElement(XformBuilder.PREFIX_XFORMS + ":" + XformBuilder.NODE_ITEM);
    itemNode.setAttribute(XformBuilder.ATTRIBUTE_ID, personId.toString());

    Element node = doc.createElement(XformBuilder.PREFIX_XFORMS + ":" + XformBuilder.NODE_LABEL);
    node.setTextContent(XformBuilder.getProviderName(user, personId));
    itemNode.appendChild(node);

    node = doc.createElement(XformBuilder.PREFIX_XFORMS + ":" + XformBuilder.NODE_VALUE);
    node.setTextContent(personId.toString());
    itemNode.appendChild(node);

    providerSelect1Element.appendChild(itemNode);
}

From source file:org.openmrs.module.xforms.aop.XformsConceptAdvisor.java

/**
 * Adds a new concept answer node to its corresponding coded concept select1 node in as xforms
 * document./*from  www . ja v a2 s  .  c o m*/
 * 
 * @param doc the xforms document.
 * @param concept the concept answer whose xforms node to add.
 * @param conceptSelect1Element the select1 element for the coded concept that has the answer we
 *            are adding.
 */
private void addNewConceptAnswer(Document doc, Concept concept, Element conceptSelect1Element) {
    String hl7Name = StringEscapeUtils.escapeXml(FormUtil.conceptToString(concept, Context.getLocale()));

    Element itemNode = doc.createElement(XformBuilder.PREFIX_XFORMS + ":" + XformBuilder.NODE_ITEM);
    itemNode.setAttribute(XformBuilder.ATTRIBUTE_CONCEPT_ID, concept.getConceptId().toString());

    Element node = doc.createElement(XformBuilder.PREFIX_XFORMS + ":" + XformBuilder.NODE_LABEL);
    node.setTextContent(XformBuilder.getConceptName(hl7Name));
    itemNode.appendChild(node);

    node = doc.createElement(XformBuilder.PREFIX_XFORMS + ":" + XformBuilder.NODE_VALUE);
    node.setTextContent(hl7Name);
    itemNode.appendChild(node);

    conceptSelect1Element.appendChild(itemNode);
}

From source file:com.hydroLibCreator.action.Creator.java

private Node createNameNode(Document document) {
    Element name = document.createElement("name");
    name.setTextContent(audioLibrary.getName());
    return name;//  w  w  w .j ava  2  s  .c  o m
}

From source file:com.hydroLibCreator.action.Creator.java

private Node createInfoNode(Document document) {
    Element info = document.createElement("info");
    info.setTextContent(audioLibrary.getInfo());
    return info;//w  ww  . j  av a  2  s.  com
}

From source file:fr.adfab.magebeans.processes.CreateModuleProcess.java

protected void _createConfigXml() {
    try {/* w  w w .  j  a  v a 2  s  .co  m*/
        DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
        this.dom = documentBuilder.newDocument();
        this.configElement = this.dom.createElement("config");
        this.globalElement = this.dom.createElement("global");

        // Create config for module version
        Element moduleElement = this.dom.createElement(this.moduleName);
        Element versionElement = this.dom.createElement("version");
        versionElement.setTextContent("0.1.0");
        moduleElement.appendChild(versionElement);
        this.configElement.appendChild(moduleElement);

        if (this.hasBlock) {
            this._createConfigNode("block");
            this._createFolders("Block");
        }

        if (this.hasModel) {
            this._createConfigNode("model");
            this._createFolders("Model");
        }

        if (this.hasHelper) {
            this._createConfigNode("helper");
            this._createFolders("Helper");
        }

        if (this.hasSetup) {
            this._createSetup();
        }

        this.configElement.appendChild(this.globalElement);
        this.dom.appendChild(this.configElement);
    } catch (ParserConfigurationException ex) {
        System.out.println(ex.getMessage());
    }
}

From source file:com.hydroLibCreator.action.Creator.java

private Node createAuthorNode(Document document) {
    Element author = document.createElement("author");
    author.setTextContent(audioLibrary.getAuthor());
    return author;
}

From source file:com.hydroLibCreator.action.Creator.java

private Node createLicenseNode(Document document) {
    Element license = document.createElement("license");
    license.setTextContent(audioLibrary.getLicense());
    return license;
}

From source file:com.photon.phresco.framework.impl.ServerPluginUtil.java

private void addJBossPlugin(File pomFile) throws PhrescoException {
    try {/*from  w  ww. jav  a2  s  .com*/
        PomProcessor pomProcessor = new PomProcessor(pomFile);
        Plugin plugin = pomProcessor.getPlugin("org.codehaus.cargo", "cargo-maven2-plugin");
        if (plugin != null) {
            return;
        }
        pomProcessor.addPlugin("org.codehaus.cargo", "cargo-maven2-plugin", "1.1.3");
        List<Element> configList = new ArrayList<Element>();
        DocumentBuilderFactory dbfac = DocumentBuilderFactory.newInstance();
        DocumentBuilder docBuilder = dbfac.newDocumentBuilder();
        Document doc = docBuilder.newDocument();
        Element containerElement = doc.createElement("container");
        Element containerId = doc.createElement("containerId");
        containerId.setTextContent("jboss7x");
        containerElement.appendChild(containerId);
        Element type = doc.createElement("type");
        type.setTextContent("remote");
        containerElement.appendChild(type);
        Element home = doc.createElement("home");
        home.setTextContent("${jboss.home}\\standalone\\deployments");
        containerElement.appendChild(home);

        Element configurationElement = doc.createElement("configuration");
        Element innerType = doc.createElement("type");
        innerType.setTextContent("runtime");
        configurationElement.appendChild(innerType);

        Element propertyElement = doc.createElement("properties");
        configurationElement.appendChild(propertyElement);
        Element cargoHome = doc.createElement("cargo.hostname");
        cargoHome.setTextContent("${server.host}");
        propertyElement.appendChild(cargoHome);
        Element cargoMgmtPort = doc.createElement("cargo.jboss.management.port");
        cargoMgmtPort.setTextContent("9999");
        propertyElement.appendChild(cargoMgmtPort);
        Element cargoRmiPort = doc.createElement("cargo.rmi.port");
        cargoRmiPort.setTextContent("1099");
        propertyElement.appendChild(cargoRmiPort);
        Element cargoUserName = doc.createElement("cargo.remote.username");
        cargoUserName.setTextContent("${server.username}");
        propertyElement.appendChild(cargoUserName);
        Element cargoPwd = doc.createElement("cargo.remote.password");
        cargoPwd.setTextContent("${server.password}");
        propertyElement.appendChild(cargoPwd);
        configurationElement.appendChild(propertyElement);

        configList.add(containerElement);
        configList.add(configurationElement);
        pomProcessor.addConfiguration("org.codehaus.cargo", "cargo-maven2-plugin", configList);

        Dependency dependency = new Dependency();
        dependency.setGroupId("org.jboss.as");
        dependency.setArtifactId("jboss-as-controller-client");
        dependency.setVersion("7.0.2.Final");

        pomProcessor.addPluginDependency("org.codehaus.cargo", "cargo-maven2-plugin", dependency);
        pomProcessor.save();

    } catch (JAXBException e) {
        throw new PhrescoException(e);
    } catch (IOException e) {
        throw new PhrescoException(e);
    } catch (ParserConfigurationException e) {
        throw new PhrescoException(e);
    } catch (PhrescoPomException e) {
        throw new PhrescoException(e);
    }
}

From source file:com.amalto.core.util.Util.java

public static void setUserProperty(Document user, String name, String value) throws Exception {
    if (name == null) {
        return;//  ww w  . java  2s .c o m
    }
    NodeList properties = Util.getNodeList(user, "//properties"); //$NON-NLS-1$
    Element propertiesElement = null;
    if (properties == null || properties.getLength() == 0) {
        propertiesElement = user.createElement("properties"); //$NON-NLS-1$
        user.getDocumentElement().appendChild(propertiesElement);
    } else {
        propertiesElement = (Element) properties.item(0);
    }
    NodeList props = Util.getNodeList(propertiesElement, "//property"); //$NON-NLS-1$
    boolean propertyFound = false;
    if (props != null) {
        for (int i = 0; i < props.getLength(); i++) {
            Node node = props.item(i);
            if (name.equals(getFirstTextNode(node, "name"))) { //$NON-NLS-1$
                propertyFound = true;
                if (getFirstTextNode(node, "value") == null) { //$NON-NLS-1$
                    getNodeList(node, "value").item(0).appendChild(user.createTextNode(value)); //$NON-NLS-1$
                } else {
                    getNodeList(node, "value").item(0).getFirstChild().setNodeValue(value); //$NON-NLS-1$
                }
            }
        }
    }
    if (!propertyFound) {
        Element propertyElement = user.createElement("property"); //$NON-NLS-1$
        propertiesElement.appendChild(propertyElement);

        Element nameElement = user.createElement("name"); //$NON-NLS-1$
        nameElement.setTextContent(name);
        propertyElement.appendChild(nameElement);

        Element valueElement = user.createElement("value"); //$NON-NLS-1$
        valueElement.setTextContent(value);
        propertyElement.appendChild(valueElement);
    }
}

From source file:org.ambraproject.search.service.IndexingServiceImpl.java

/**
 *  Add the article-strkImg tag as a child  to the article-meta
 *  tag of the article ml.//from w w w  .j a  v  a 2 s  .  c o  m
 */
private Document addStrikingImage(Document doc, String strkImagURI) {
    NodeList metaNodeLst = doc.getElementsByTagName("article-meta");
    Node metaNode = metaNodeLst.item(0);
    Element strkImgElem = doc.createElement("article-strkImg");

    strkImgElem.setTextContent(strkImagURI);
    metaNode.appendChild(strkImgElem.cloneNode(true));
    return doc;
}