Example usage for org.w3c.dom Element getTextContent

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

Introduction

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

Prototype

public String getTextContent() throws DOMException;

Source Link

Document

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

Usage

From source file:eu.aniketos.scpm.userinterface.views.ScpmUI.java

/**
 * @see loadBPMN When generates a *.activiti file from *.bpmn20.xml file,
 *      The Activiti designer only copes with the original tags/elements.
 *      Any security extensions that embedded in the composition plan by SCF
 *      have to be abstracted manually. This method looks for security
 *      extensions in the XML file.//from w  w w .  ja v a  2 s  .  c o m
 * 
 * @param serviceElement
 *            The element to be parsed.
 * @return Values of the extended attributes.
 */
private static List<String> getExtensions(org.w3c.dom.Element serviceElement) {

    List<String> attValues = new Vector<String>();
    NodeList attList = serviceElement.getElementsByTagName("activiti:field");

    for (int index = 0; index < attList.getLength(); index++) {

        Node attNode = attList.item(index);
        if (attNode.getNodeType() == Node.ELEMENT_NODE) {

            org.w3c.dom.Element attElement = (org.w3c.dom.Element) attNode;
            // have to guess the type of the value.
            NodeList valueList = attElement.getElementsByTagName("activiti:string");
            if (valueList.getLength() == 0)
                valueList = attElement.getElementsByTagName("activiti:expression");
            // assume there is only one child that contains the value
            org.w3c.dom.Element valueElement = (org.w3c.dom.Element) valueList.item(0);
            attValues.add(valueElement.getTextContent());

        }
    }
    return attValues;

}

From source file:org.gvnix.addon.jpa.addon.entitylistener.JpaOrmEntityListenerOperationsImpl.java

/**
 * @param current/*from  w w  w  . j  a v a 2 s .c om*/
 * @return
 */
private String getEntityListenerElementType(Element current) {
    Element description = XmlUtils.findFirstElement("/description", current);
    if (description == null) {
        return null;
    }
    return description.getTextContent();
}

From source file:com.moviejukebox.reader.MovieNFOReader.java

/**
 * Parse all the IDs associated with the movie from the XML NFO file
 *
 * @param nlElements//from w  w  w .  j  a  v a 2s.c o  m
 * @param movie
 * @param isTv
 */
private static void parseIds(NodeList nlElements, Movie movie, boolean isTv) {
    Node nElements;
    for (int looper = 0; looper < nlElements.getLength(); looper++) {
        nElements = nlElements.item(looper);
        if (nElements.getNodeType() == Node.ELEMENT_NODE) {
            Element eId = (Element) nElements;

            String movieDb = eId.getAttribute("moviedb");
            if (StringTools.isNotValidString(movieDb)) {
                // Decide which default plugin ID to use
                if (isTv) {
                    movieDb = TheTvDBPlugin.THETVDB_PLUGIN_ID;
                } else {
                    movieDb = ImdbPlugin.IMDB_PLUGIN_ID;
                }
            }

            setMovieId(movie, movieDb, eId.getTextContent());

            // Process the TMDB id
            setMovieId(movie, TheMovieDbPlugin.TMDB_PLUGIN_ID, eId.getAttribute("TMDB"));
        }
    }
}

From source file:com.photon.phresco.framework.rest.api.BuildInfoService.java

private List<MinifyInfo> includesFiles(Element element, String appDirName) throws PhrescoException {
    List<MinifyInfo> consoldateInfo = new ArrayList<MinifyInfo>();
    String opFileLoc = "";
    try {/* www.  ja  va  2  s . c  o  m*/
        if (POM_AGGREGATIONS.equals(element.getNodeName())) {
            NodeList aggregationList = element.getElementsByTagName(POM_AGGREGATION);
            for (int i = 0; i < aggregationList.getLength(); i++) {
                MinifyInfo minifyInfo = new MinifyInfo();
                Element childNode = (Element) aggregationList.item(i);
                NodeList includeList = childNode.getElementsByTagName(POM_INCLUDES).item(0).getChildNodes();
                StringBuilder csvFileNames = new StringBuilder();
                String sep = "";
                for (int j = 0; j < includeList.getLength() - 1; j++) {//To convert select files to Comma seperated value
                    Element include = (Element) includeList.item(j);
                    String file = include.getTextContent()
                            .substring(include.getTextContent().lastIndexOf(FILE_SEPARATOR) + 1);
                    csvFileNames.append(sep);
                    csvFileNames.append(file);
                    sep = COMMA;
                }
                Element outputElement = (Element) childNode.getElementsByTagName(POM_OUTPUT).item(0);
                //To get compressed name with extension
                String opFileName = outputElement.getTextContent()
                        .substring(outputElement.getTextContent().lastIndexOf(FILE_SEPARATOR) + 1);
                String compressName = opFileName.substring(0, opFileName.indexOf("."));//To get only the compressed name without extension
                String compressedExtension = opFileName
                        .substring(opFileName.lastIndexOf(FrameworkConstants.DOT) + 1);//To get extension of compressed file
                opFileLoc = outputElement.getTextContent().substring(0,
                        outputElement.getTextContent().lastIndexOf(FILE_SEPARATOR) + 1);
                opFileLoc = opFileLoc.replace(MINIFY_OUTPUT_DIRECTORY,
                        FrameworkServiceUtil.getApplicationHome(appDirName).replace(File.separator,
                                FrameworkConstants.FORWARD_SLASH));

                if (JS.equals(compressedExtension)) {//if extension is js , add minified details to jsMap
                    minifyInfo.setFileType(JS);
                    minifyInfo.setCompressName(compressName);
                    minifyInfo.setCsvFileName(csvFileNames.toString().replace(HYPHEN_MIN, ""));
                    minifyInfo.setOpFileLoc(opFileLoc);
                } else {//if extension is CSS , add minified details to cssMap
                    minifyInfo.setFileType("css");
                    minifyInfo.setCompressName(compressName);
                    minifyInfo.setCsvFileName(csvFileNames.toString().replace(HYPHEN_MIN, ""));
                    minifyInfo.setOpFileLoc(opFileLoc);
                }
                consoldateInfo.add(minifyInfo);
            }
        }
    } catch (Exception e) {
        throw new PhrescoException(e);
    }
    return consoldateInfo;
}

From source file:org.gvnix.dynamic.configuration.roo.addon.ConfigurationsImpl.java

/**
 * {@inheritDoc}//from w ww .  j  a  v a 2  s . c o  m
 */
public DynConfiguration getActiveConfiguration() {

    DynConfiguration dynConf = null;

    Element elem = XmlUtils.findFirstElement(ACTIVE_CONFIGURATION_XPATH,
            getConfigurationDocument().getDocumentElement());
    if (elem != null) {

        Element active = findConfiguration(elem.getTextContent());
        if (active != null) {
            dynConf = parseConfiguration(active, null);
        }
    }

    return dynConf;
}

From source file:com.evolveum.midpoint.testing.model.client.sample.TestExchangeConnector.java

private static String getOrig(PolyStringType polyStringType) {
    if (polyStringType == null) {
        return null;
    }/* w w  w.  jav a2 s .  c o m*/
    StringBuilder sb = new StringBuilder();
    for (Object o : polyStringType.getContent()) {
        if (o instanceof String) {
            sb.append(o);
        } else if (o instanceof Element) {
            Element e = (Element) o;
            if ("orig".equals(e.getLocalName())) {
                return e.getTextContent();
            }
        } else if (o instanceof JAXBElement) {
            JAXBElement je = (JAXBElement) o;
            if ("orig".equals(je.getName().getLocalPart())) {
                return (String) je.getValue();
            }
        }
    }
    return sb.toString();
}

From source file:eu.europa.esig.dss.tsl.service.TSLParser.java

private void fillPointerTerritoryAndMimeType(OtherTSLPointerType otherTSLPointerType, TSLPointer pointer) {
    List<Serializable> textualInformationOrOtherInformation = otherTSLPointerType.getAdditionalInformation()
            .getTextualInformationOrOtherInformation();
    if (CollectionUtils.isNotEmpty(textualInformationOrOtherInformation)) {
        Map<String, String> properties = new HashMap<String, String>();
        for (Serializable serializable : textualInformationOrOtherInformation) {
            if (serializable instanceof AnyType) {
                AnyType anyInfo = (AnyType) serializable;
                for (Object content : anyInfo.getContent()) {
                    if (content instanceof JAXBElement) {
                        @SuppressWarnings("rawtypes")
                        JAXBElement jaxbElement = (JAXBElement) content;
                        properties.put(jaxbElement.getName().toString(), jaxbElement.getValue().toString());
                    } else if (content instanceof Element) {
                        Element element = (Element) content;
                        properties.put("{" + element.getNamespaceURI() + "}" + element.getLocalName(),
                                element.getTextContent());
                    }/*from www .j ava2 s.  com*/
                }
            }
        }
        pointer.setMimeType(properties.get("{http://uri.etsi.org/02231/v2/additionaltypes#}MimeType"));
        pointer.setTerritory(properties.get("{http://uri.etsi.org/02231/v2#}SchemeTerritory"));
    }
}

From source file:ambit.data.qmrf.QMRFAttachment.java

public void fromXML(Element xml) throws XMLException {
    setFiletype(xml.getAttribute(attribute_filetype));
    setUrl(xml.getAttribute(attribute_url));
    setDescription(xml.getAttribute(attribute_description));
    String s = xml.getAttribute(attribute_embedded);

    if (s == null)
        setEmbedded(false);/*from   www . java  2 s  . c  om*/
    else
        setEmbedded("YES".equals(s.toString()));
    if (getEmbedded()) {
        try {
            String c = xml.getTextContent();
            content = new String(Base64.decodeBase64(c.getBytes(UTF8charset)), UTF8charset);
        } catch (Exception x) {
            throw new XMLException(x);

        }

    } else
        setContent(null);
}

From source file:com.QuarkLabs.BTCeClientJavaFX.MainController.java

/**
 * Loads exchange pairs and currencies from XML file, displays error message at the Log field in case of any Exception
 *//*from  w w w.ja  v  a2s .  c  om*/
private void loadExchangeConfig() {

    try {
        InputStream inputStream = new FileInputStream(EXCHANGE_CONFIG_PATH);
        DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
        DocumentBuilder builder = builderFactory.newDocumentBuilder();
        Document document = builder.parse(inputStream);
        document.getDocumentElement().normalize();
        NodeList nodeList = document.getElementsByTagName("currency");
        for (int i = 0; i < nodeList.getLength(); i++) {
            Node node = nodeList.item(i);
            if (node.getNodeType() == Node.ELEMENT_NODE) {
                Element eElement = (Element) node;
                currencies.add(eElement.getTextContent());
            }
        }
        nodeList = document.getElementsByTagName("pair");
        for (int i = 0; i < nodeList.getLength(); i++) {
            Node node = nodeList.item(i);
            if (node.getNodeType() == Node.ELEMENT_NODE) {
                Element eElement = (Element) node;
                pairs.add(eElement.getTextContent());
            }
        }
        inputStream.close();
    } catch (ParserConfigurationException | SAXException | IOException e) {
        logField.appendText(e.getMessage() + "\r\n");
    }
}

From source file:betullam.xmlmodifier.XMLmodifier.java

private List<Node> getElementsToModify(String mdName, String mdValue, Document xmlDoc)
        throws XPathExpressionException {
    List<Node> nodeArrayList = new ArrayList<Node>();

    if (!mdName.equals("null")) {
        XPathFactory xPathFactory = XPathFactory.newInstance();
        XPath xPath = xPathFactory.newXPath();
        XPathExpression xPathExpr = xPath.compile("//goobi/metadata[@name=\"" + mdName + "\"]");
        NodeList nodeList = (NodeList) xPathExpr.evaluate(xmlDoc, XPathConstants.NODESET);
        if (mdValue.equals("null")) {
            for (int n = 0; n < nodeList.getLength(); n++) {
                nodeArrayList.add(nodeList.item(n));
            }/*from  w  ww  .j  av  a  2 s  .c o m*/
        } else {
            for (int n = 0; n < nodeList.getLength(); n++) {
                Element xmlElement = (Element) nodeList.item(n);
                String textContent = xmlElement.getTextContent();
                if (textContent.equals(mdValue)) {
                    nodeArrayList.add(nodeList.item(n));
                }
            }
        }
    }

    return nodeArrayList;
}