/** * Returns the XPath 1.0 string value of this element, which is the * complete, ordered content of all text node descendants of this element * (i.e. the text that's left after all references are resolved * and all other markup is stripped out.) * * @return a concatentation of all text node descendants */ @Override public String getValue() { final StringBuilder buffer = new StringBuilder(); for (Content child : getContent()) { if (child instanceof Element || child instanceof Text) { buffer.append(child.getValue()); } } return buffer.toString(); }
if (c instanceof Text) { if (!Verifier.isAllXMLWhitespace(c.getValue())) { break; if (c instanceof Text) { if (!Verifier.isAllXMLWhitespace(c.getValue())) { break; switch (c.getCType()) { case Text : mtext.appendText(trim, c.getValue()); break; case CDATA : mtext.appendCDATA(trim, c.getValue()); break; case EntityRef:
} else if (o instanceof Content) { Content c = (Content) o; values.add(constructPair(outputField.field, c.getValue())); } else if (o instanceof Document) { Document d = (Document) o;
if (previousElement.getName().equals("divider")) { if (bodyElementContentSize == 0 || (bodyElementContentSize == 1 && bodyElement.getContent().get(0).getValue().isEmpty())) { currentElement.detach();
@Test public void checkGridAsPointXml() throws JDOMException, IOException { String endpoint = TestOnLocalServer.withHttpPath(ds + "?var=" + varName + query + "&accept=xml"); byte[] result = TestOnLocalServer.getContent(endpoint, 200, ContentType.xml); Assert.assertNotNull(result); String xml = new String( result); logger.debug("xml={}", xml); Reader in = new StringReader(xml); SAXBuilder sb = new SAXBuilder(); Document doc = sb.build(in); String xpathq = String.format("/stationFeatureCollection/stationFeature"); logger.debug("xpathq='{}'", xpathq); XPathExpression <Element> xpath = XPathFactory.instance().compile(xpathq, Filters.element()); List<Element> elements = xpath.evaluate(doc); Assert.assertEquals((int) ntimes, elements.size()); Element elem0 = elements.get(0); CalendarDate cd = CalendarDate.parseISOformat(null, elem0.getAttributeValue("date")); logger.debug(" xml date={}", cd); Assert.assertEquals(date0, cd); xpathq = String.format("/stationFeatureCollection/stationFeature/data[@name='%s']", varName); logger.debug("xpathq='{}'", xpathq); xpath = XPathFactory.instance().compile(xpathq, Filters.element()); elements = xpath.evaluate(doc); Assert.assertEquals((int) ntimes, elements.size()); elem0 = elements.get(0); double val = Double.parseDouble(elem0.getContent(0).getValue()); Assert2.assertNearlyEquals(dataVal, val); }