List of usage examples for org.w3c.dom Node getTextContent
public String getTextContent() throws DOMException;
From source file:it.pronetics.madstore.crawler.publisher.impl.AtomPublisherImpl.java
private String getOrGenerateEntryKey(Element entry) throws Exception { String key = entry.getAttribute(AtomConstants.ATOM_KEY); if (key == null || key.equals("")) { LOG.warn("No entry key found, generating surrogate key ..."); NodeList titleNodes = entry.getElementsByTagName(AtomConstants.ATOM_ENTRY_TITLE); Node titleNode = titleNodes.item(0); if (titleNode != null) { int keyCode = titleNode.getTextContent().hashCode(); if (keyCode < 0) { key = "e" + Integer.toString(keyCode * -1) + "n"; } else { key = "e" + Integer.toString(keyCode) + "p"; }/*from ww w.java2 s . co m*/ } else { key = Long.toString(System.currentTimeMillis()); } entry.setAttribute(AtomConstants.ATOM_KEY, key); LOG.warn("Surrogated entry key: {}", key); } return key; }
From source file:de.escidoc.core.test.oai.oaiprovider.OaiproviderTestBase.java
/** * Inserts a unique label into the provided document by adding the current timestamp to the contained label. * * @param document The document./*from ww w. jav a2s. c o m*/ * @return The inserted login name. * @throws Exception If anything fails. */ protected String insertUniqueSetSpecification(final Document document) throws Exception { assertXmlExists("No specification found in template data. ", document, "/set-definition/specification"); final Node specNode = selectSingleNode(document, "/set-definition/specification"); String specification = specNode.getTextContent().trim(); specification += System.currentTimeMillis(); specNode.setTextContent(specification); return specification; }
From source file:it.geosolutions.geobatch.migrationmonitor.statuschecker.CheckerAction.java
public String extractEntry(String entryName, NodeList entries) { String text = ""; boolean found = false; for (int i = 0; i < entries.getLength(); i++) { Node n = entries.item(i); NodeList cn = n.getChildNodes(); for (int j = 0; j < cn.getLength(); j++) { Node tmp = cn.item(j); if (tmp.getNodeType() == Node.ELEMENT_NODE) { String tmpText = tmp.getTextContent(); if (tmpText.equals(entryName)) { found = true;// w w w. ja va 2 s.c om } else { text = tmpText; } } } if (found) { return text; } } return null; }
From source file:nl.surfnet.sab.SabResponseParser.java
public SabRoleHolder parse(InputStream inputStream) throws IOException { String organisation = null;/* ww w. j a v a 2s . co m*/ List<String> roles = new ArrayList<String>(); XPath xpath = getXPath(); try { Document document = createDocument(inputStream); validateStatus(document, xpath); // Extract organisation XPathExpression organisationExpr = xpath.compile(XPATH_ORGANISATION); NodeList nodeList = (NodeList) organisationExpr.evaluate(document, XPathConstants.NODESET); for (int i = 0; nodeList != null && i < nodeList.getLength(); i++) { Node node = nodeList.item(i); if (node != null) { organisation = StringUtils.trimWhitespace(node.getTextContent()); node.getParentNode().getTextContent(); } } // Extract roles XPathExpression rolesExpr = xpath.compile(XPATH_ROLES); NodeList rolesNodeList = (NodeList) rolesExpr.evaluate(document, XPathConstants.NODESET); for (int i = 0; rolesNodeList != null && i < rolesNodeList.getLength(); i++) { Node node = rolesNodeList.item(i); if (node != null) { roles.add(StringUtils.trimWhitespace(node.getTextContent())); } } } catch (XPathExpressionException e) { throw new RuntimeException(e); } catch (ParserConfigurationException e) { throw new RuntimeException(e); } catch (SAXException e) { throw new IOException(e); } return new SabRoleHolder(organisation, roles); }
From source file:eu.impact_project.wsclient.HtmlServiceProvider.java
private Service createServiceObjectFor(Node a, int id) { String title = formatTitle(a.getTextContent()); String wsdlPath = a.getAttributes().getNamedItem("href").getTextContent(); URL wsdlUrl = null;/*from w w w. j av a 2 s.c o m*/ try { wsdlUrl = new URL(configUrl + wsdlPath); } catch (MalformedURLException e) { e.printStackTrace(); } String description = getWsdlDescription(wsdlUrl); Service result = new HtmlService(id, title, description, wsdlUrl); return result; }
From source file:org.shareok.data.plosdata.PlosApiDataImpl.java
private Map<String, String> getArticleMapData(Element ele) { Map<String, String> mapData = new HashMap<>(); NodeList eleChildren = ele.getChildNodes(); for (int childIndex = 0; childIndex < eleChildren.getLength(); childIndex++) { Node node = eleChildren.item(childIndex); String nodeName = node.getNodeName(); NamedNodeMap attributes = node.getAttributes(); if (attributes.getLength() > 0) { Node item = attributes.item(0); String attributeVal = item.getNodeValue(); String val = ""; if (nodeName.equals("arr")) { NodeList children = node.getChildNodes(); for (int j = 0; j < children.getLength(); j++) { Node child = children.item(j); if (child.getNodeName().equals("str")) { val += child.getTextContent() + "; "; }/*from w w w . ja v a2 s . c o m*/ } } else { val = node.getTextContent(); } val = val.trim(); if (val.endsWith(";")) { val = val.substring(0, val.length() - 1); } if (attributeVal.equals("publication_date")) { attributeVal = "publication date"; try { val = DataHandlersUtil.convertPubTimeFormat(val); } catch (ParseException ex) { logger.error( "Cannot convert the publication time from yyyy-MM-dd'T'HH:mm:ss to yyyy-MM-dd format", ex); } } mapData.put(attributeVal, val); } } return mapData; }
From source file:io.fabric8.tooling.archetype.ArchetypeUtils.java
public String firstElementText(Element root, String elementName, String defaultValue) { // prefer direct children first String answer = null;//from w w w . j a v a 2 s . co m NodeList children = root.getChildNodes(); for (int cn = 0; cn < children.getLength(); cn++) { if (elementName.equals(children.item(cn).getNodeName())) { answer = children.item(cn).getTextContent(); break; } } if (answer == null) { // fallback to getElementsByTagName children = root.getElementsByTagName(elementName); if (children.getLength() == 0) { answer = defaultValue; } else { Node first = children.item(0); answer = first.getTextContent(); } } return answer == null ? defaultValue : answer; }
From source file:net.bpelunit.framework.control.deploy.activevos9.ActiveVOSAdministrativeFunctions.java
public void deployBpr(String bprFileName, byte[] contents) throws DeployException { AesDeployBprType deployBprInput = new AesDeployBprType(); AesStringResponseType deployBpr;/*from w w w .ja v a 2 s. c o m*/ deployBprInput.setBprFilename(bprFileName); deployBprInput.setBase64File(contents); deployBpr = getActiveBpelAdminPort().deployBpr(deployBprInput); String responseMessage = deployBpr.getResponse(); try { Document xml = XMLUtil.parseXML(responseMessage); Node item = xml.getFirstChild().getAttributes().getNamedItem(ATTRIBUTE_ERROR_COUNT); if (Integer.parseInt(item.getTextContent()) != 0) { throw new DeployException("Errors while deploying process: " + responseMessage); } } catch (ParserConfigurationException e) { throw new DeployException("Internal error: " + e.getMessage(), e); } catch (SAXException e) { throw new DeployException("Internal reading response XML: " + e.getMessage(), e); } catch (IOException e) { throw new DeployException(e.getMessage(), e); } }
From source file:de.rub.nds.burp.utilities.attacks.signatureFaking.SignatureFakingOracle.java
private boolean isSignatureMethodSupported(Node signatureMethodElement) { NamedNodeMap nl = signatureMethodElement.getAttributes(); Node n = nl.getNamedItem("Algorithm"); if (n != null) { String algorithm = n.getTextContent(); if (algorithm.contains("rsa-sha")) { return true; }/*from w w w .jav a 2s. com*/ } return false; }
From source file:com.hyunnyapp.yahooweathergatter.WOEIDUtils.java
private String getTextContentByTagName(Document srcDoc, String tagName) { NodeList nodeListDescription = srcDoc.getElementsByTagName(tagName); if (nodeListDescription.getLength() > 0) { Node node = nodeListDescription.item(0); return node.getTextContent(); }/*from www . j a v a2s . co m*/ return null; }