List of usage examples for org.w3c.dom Node getTextContent
public String getTextContent() throws DOMException;
From source file:com.uber.jenkins.phabricator.coverage.CoberturaXMLParser.java
private List<String> getSourceDirs(Document doc) { if (workspace == null) { return Collections.emptyList(); }/*from w ww . j a v a2 s. c o m*/ List<String> sourceDirs = new ArrayList<String>(); NodeList sources = doc.getElementsByTagName(TAG_NAME_SOURCE); for (int i = 0; i < sources.getLength(); i++) { Node source = sources.item(i); String srcDir = source.getTextContent(); if (srcDir.contains(workspace + "/")) { String relativeSrcDir = srcDir.replaceFirst(workspace + "/", ""); if (!relativeSrcDir.isEmpty()) { sourceDirs.add(relativeSrcDir); } } } return sourceDirs; }
From source file:cn.liutils.cgui.loader.xml.CGUIDocLoader.java
private void parseComponent(Node n, Widget target) { NodeList nl = n.getChildNodes(); Map<String, String> propertyMap = new HashMap(); String clazz = ((Element) n).getAttribute("class"); for (int i = 0; i < nl.getLength(); ++i) { Node n2 = nl.item(i); propertyMap.put(n2.getNodeName(), n2.getTextContent()); }//from ww w . j av a 2 s .co m if (clazz == null) { throw new RuntimeException("didn't find one of the component class when parsing CGUI document."); } Component c = null; try { c = (Component) Class.forName(clazz).newInstance(); } catch (Exception e) { LIUtils.log.error("An error occured trying to instantiate class " + clazz, e); } c.fromPropertyMap(propertyMap); target.addComponent(c); if (c.name.equals("Transform")) { target.transform = (Transform) c; } }
From source file:com.stevpet.sonar.plugins.dotnet.resharper.customseverities.BaseCustomSeverities.java
private RulePriority getRulePriority(Node node) { String severityText = node.getTextContent(); ReSharperSeverity reSharperSeverity = ReSharperUtils.getResharperSeverity(severityText); return ReSharperUtils.translateResharperPriorityIntoSonarPriority(reSharperSeverity); }
From source file:gov.nih.nci.cacis.ip.mirthconnect.CanonicalModelProcessorVirtuosoIntegrationTest.java
@Test public void invokeSOAP() throws Exception { final Node res = invoke(ADDRESS, SoapTransportFactory.TRANSPORT_ID, getValidMessage().getBytes()); assertNotNull(res);//w ww. j av a 2 s. c o m LOG.info("Echo response: " + res.getTextContent()); // Wait for MC to call CDWLoader Thread.sleep(30000); int grphTriplesCnt = getNoOfTriples(dbaSimpleJdbcTemplate, site1URI); assertTrue(grphTriplesCnt > 0); grphTriplesCnt = getNoOfTriples(dbaSimpleJdbcTemplate, study1URI); assertTrue(grphTriplesCnt > 0); grphTriplesCnt = getNoOfTriples(dbaSimpleJdbcTemplate, p1URI); assertTrue(grphTriplesCnt > 0); }
From source file:org.apache.solr.kelvin.responseanalyzers.XmlDoclistExtractorResponseAnalyzer.java
public void decode(Map<String, Object> previousResponses) throws Exception { ObjectMapper mapper = new ObjectMapper(); ArrayNode response = mapper.createArrayNode(); if (!previousResponses.containsKey(XmlResponseAnalyzer.XML_DOM)) { previousResponses.put(DOC_LIST, response); //empty return;//from w w w. j av a 2s . c o m } NodeList nodeList = (NodeList) expr.evaluate((Document) previousResponses.get(XmlResponseAnalyzer.XML_DOM), XPathConstants.NODESET); for (int i = 0; i < nodeList.getLength(); i++) { Node doc = nodeList.item(i); ObjectNode oDoc = mapper.createObjectNode(); Node subel = doc.getFirstChild(); while (subel != null) { if (subel.getNodeType() != Node.TEXT_NODE) { String fieldName = subel.getAttributes().getNamedItem("name").getNodeValue(); String elementName = subel.getNodeName(); if ("arr".equals(elementName)) { ArrayNode multivaluedField = mapper.createArrayNode(); Node mvItem = subel.getFirstChild(); while (mvItem != null) { multivaluedField.add(mvItem.getTextContent()); mvItem = mvItem.getNextSibling(); } oDoc.put(fieldName, multivaluedField); } else { String value = subel.getTextContent(); oDoc.put(fieldName, value); } } subel = subel.getNextSibling(); } response.add(oDoc); } previousResponses.put(DOC_LIST, response); }
From source file:au.com.ors.rest.controller.AutoCheckController.java
@RequestMapping(method = RequestMethod.POST) @ResponseBody/*from www.ja v a2s .co m*/ public ResponseEntity<AutoCheckRes> autoCheck(@RequestBody AutoCheckReq req) throws Exception { AutoCheckRes autoCheckRes = new AutoCheckRes(null, null); SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance(); SOAPConnection soapConnection = soapConnectionFactory.createConnection(); String url = "http://localhost:6060/ode/processes/AutoCheck"; SOAPMessage soapResponse = soapConnection .call(createSOAPRequest(req.getDriverLicenseNumber(), req.getFullName(), req.getPostCode()), url); soapConnection.close(); SOAPBody body = soapResponse.getSOAPBody(); Node rootnode = body.getChildNodes().item(0); NodeList nodeList = rootnode.getChildNodes(); for (int i = 0; i < nodeList.getLength(); ++i) { Node currentNode = nodeList.item(i); if (currentNode.getNodeName().equals("ns:pdvResult")) { autoCheckRes.setPdvResult(currentNode.getTextContent()); } else if (currentNode.getNodeName().equals("ns:crvResult")) { autoCheckRes.setCrvResult(currentNode.getTextContent()); } } return new ResponseEntity<AutoCheckRes>(autoCheckRes, HttpStatus.OK); }
From source file:co.edu.uniajc.vtf.utils.GMapV2Direction.java
public String getCopyRights(Document doc) { NodeList nl1 = doc.getElementsByTagName("copyrights"); Node node1 = nl1.item(0); Log.i("CopyRights", node1.getTextContent()); return node1.getTextContent(); }
From source file:co.edu.uniajc.vtf.utils.GMapV2Direction.java
public String getStartAddress(Document doc) { NodeList nl1 = doc.getElementsByTagName("start_address"); Node node1 = nl1.item(0); Log.i("StartAddress", node1.getTextContent()); return node1.getTextContent(); }
From source file:co.edu.uniajc.vtf.utils.GMapV2Direction.java
public String getEndAddress(Document doc) { NodeList nl1 = doc.getElementsByTagName("end_address"); Node node1 = nl1.item(0); Log.i("StartAddress", node1.getTextContent()); return node1.getTextContent(); }
From source file:com.vitembp.services.imaging.OverlayDefinition.java
/** * Initializes a new instance of the OverlayDefinition class. * @param toBuildFrom //from w ww . java 2s . c o m */ private OverlayDefinition(String toBuildFrom) throws IOException { // load the definition from XML using xpath methods // first parse the document Document def; try { def = DocumentBuilderFactory.newInstance().newDocumentBuilder() .parse(new ByteArrayInputStream(toBuildFrom.getBytes(Charsets.UTF_8))); } catch (ParserConfigurationException | SAXException | IOException ex) { throw new IOException("Could not parse XML input.", ex); } // prevents issues caused by parser returning multiple text elements for // a single text area def.getDocumentElement().normalize(); // get the overlay type XPath xPath = XPathFactory.newInstance().newXPath(); try { Node type = (Node) xPath.evaluate("/overlay/type", def, XPathConstants.NODE); this.overlayType = OverlayType.valueOf(type.getTextContent()); } catch (XPathExpressionException | IllegalArgumentException ex) { throw new IOException("Exception parsing type.", ex); } // get element definitions try { NodeList elements = (NodeList) xPath.evaluate("/overlay/elements/element", def, XPathConstants.NODESET); this.elementDefinitions = new ArrayList<>(); for (int i = 0; i < elements.getLength(); i++) { this.elementDefinitions.add(new ElementDefinition(elements.item(i))); } } catch (XPathExpressionException | IllegalArgumentException ex) { throw new IOException("Exception parsing elements.", ex); } }