Example usage for org.w3c.dom Node getTextContent

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

Introduction

In this page you can find the example usage for org.w3c.dom Node 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:de.escidoc.core.test.om.container.ContainerReferenceTest.java

/**
 * Check the References within the Properties section. It is not checked if the reference is retrievable. Here is
 * the logic of the id checked./*w  w w.  j a  v  a  2 s.c om*/
 *
 * @param containerXml The XML of the Container.
 * @param id           The id which was used for the retrieve.
 * @throws Exception Thrown if the ids within the properties section doesn't fit to the retrieve Id.
 */
private void checkSoapPropertiesReferences(final String containerXml, final String id) throws Exception {

    Document containerDoc = EscidocRestSoapTestBase.getDocument(containerXml);

    Node n = selectSingleNode(containerDoc, "/container/properties/version/@objid");
    String currentVersion = n.getNodeValue();

    Node n2 = selectSingleNode(containerDoc, "/container/properties/version/number");
    String versionNumber = n2.getTextContent();

    assertEquals("This version id is wrong", id + ":" + versionNumber, currentVersion);

}

From source file:com.github.podd.resources.RestletPoddClientImpl.java

private static void printNote(NodeList nodeList) {

    for (int count = 0; count < nodeList.getLength(); count++) {

        Node tempNode = nodeList.item(count);

        // make sure it's element node.
        if (tempNode.getNodeType() == Node.ELEMENT_NODE) {

            // get node name and value
            if (!tempNode.getNodeName().startsWith("rdf:") && tempNode.getTextContent().length() > 0) {
                if (tempNode.getNodeName().startsWith("rdfs:label")) {

                    System.out.println("Name" + ": " + tempNode.getTextContent());
                } else if (tempNode.getNodeName().startsWith("rdfs:comment")) {
                    System.out.println("Description" + ": " + tempNode.getTextContent());
                } else if (tempNode.getNodeName().startsWith("hasPotColumnNumberOverall")) {
                    System.out.println("Lane" + ": " + tempNode.getTextContent());
                } else if (tempNode.getNodeName().startsWith("hasPotPositionTray")) {
                    System.out.println("Position" + ": " + tempNode.getTextContent());
                } else {
                    System.out.println(tempNode.getNodeName() + ": " + tempNode.getTextContent());
                }/*from  w ww  .  j a v a 2  s  . c o  m*/

            }

            if (tempNode.hasChildNodes()) {
                // loop again if has child node

                printNote(tempNode.getChildNodes());
                System.out.println("");

            }

        }

    }
}

From source file:de.bayern.gdi.services.CatalogService.java

/**
 * Constructor.//from   w w  w.j a  v  a 2 s.c  o  m
 *
 * @param url      URL
 * @param userName Username
 * @param password Password
 * @throws URISyntaxException if URL is wrong
 * @throws IOException if something in IO is wrong
 */
public CatalogService(URL url, String userName, String password) throws URISyntaxException, IOException {
    this.catalogURL = url;
    this.userName = userName;
    this.password = password;
    this.context = new NamespaceContextMap("csw", CSW_NAMESPACE, "gmd", GMD_NAMESPACE, "ows", OWS_NAMESPACE,
            "srv", SRV_NAMESPACE, "gco", GCO_NAMESPACE);
    Document xml = XML.getDocument(this.catalogURL, this.userName, this.password);
    if (xml != null) {
        String getProviderExpr = "//ows:ServiceIdentification/ows:Title";
        Node providerNameNode = (Node) XML.xpath(xml, getProviderExpr, XPathConstants.NODE, context);
        this.providerName = providerNameNode.getTextContent();
        String getRecordsURLExpr = "//ows:OperationsMetadata" + "/ows:Operation[@name='GetRecords']"
                + "/ows:DCP" + "/ows:HTTP" + "/ows:Post";

        NodeList rL = (NodeList) XML.xpath(xml, getRecordsURLExpr, XPathConstants.NODESET, context);

        for (int i = 0; i < rL.getLength(); i++) {
            Node gruNode = rL.item(i);
            String getRecordsValueStr = (String) XML.xpath(gruNode, "ows:Constraint/ows:Value/text()",
                    XPathConstants.STRING, this.context);

            if (getRecordsValueStr == null || getRecordsValueStr.isEmpty()
                    || getRecordsValueStr.equals("XML")) {

                String getRecordsURLStr = (String) XML.xpath(gruNode, "@*[name()='xlink:href']",
                        XPathConstants.STRING, this.context);

                this.getRecordsURL = null;
                this.getRecordsURL = new URL(getRecordsURLStr);
                break;
            }
        }
    }
}

From source file:com.amalto.core.history.accessor.ManyFieldAccessor.java

public String get() {
    Node collectionItemNode = getCollectionItemNode();
    Node firstChild = collectionItemNode.getFirstChild();
    if (firstChild != null) {
        if (firstChild instanceof Text)
            return collectionItemNode.getTextContent();// get node value can not handle bracket well
        else/*from  w ww. j a  va2s. c om*/
            return firstChild.getNodeValue();
    } else {
        return StringUtils.EMPTY;
    }
}

From source file:com.esri.gpt.server.openls.provider.services.reversegeocode.ReverseGeocodeProvider.java

/**
 * Parses reverse geocode request./*from   ww w. j a v  a 2  s . c o m*/
 * @param context
 * @param ndReq
 * @param xpath
 * @throws XPathExpressionException
 */
private void parseRequest(OperationContext context, Node ndReq, XPath xpath) throws XPathExpressionException {
    ReverseGeocodeParams reqParams = context.getRequestOptions().getReverseGeocodeOptions();
    Node ndPosition = (Node) xpath.evaluate("xls:Position", ndReq, XPathConstants.NODE);
    if (ndPosition != null) {
        Node ndPoint = (Node) xpath.evaluate("gml:Point", ndPosition, XPathConstants.NODE);
        if (ndPoint != null) {
            Node ndPos = (Node) xpath.evaluate("gml:pos", ndPoint, XPathConstants.NODE);
            if (ndPos != null) {
                String[] vals = ndPos.getTextContent().split(" ");
                reqParams.setLat(vals[0]);
                reqParams.setLng(vals[1]);
            }
        }
    }
    Node ndPreference = (Node) xpath.evaluate("xls:ReverseGeocodePreference", ndReq, XPathConstants.NODE);
    if (ndPreference != null) {
        reqParams.setPreference(ndPreference.getTextContent());
    }
}

From source file:com.github.podd.resources.RestletPoddClientImpl.java

private static void printNote2(NodeList nodeList, int prevValue) {

    for (int count = 0; count < nodeList.getLength(); count++) {

        Node tempNode = nodeList.item(count);

        // make sure it's element node.
        if (tempNode.getNodeType() == Node.ELEMENT_NODE) {

            // get node name and value
            if (!tempNode.getNodeName().startsWith("rdf:") && tempNode.getTextContent().length() > 0) {
                if (tempNode.getNodeName().startsWith("rdfs:label")) {

                    System.out.println("Name" + ": " + tempNode.getTextContent());
                } else if (tempNode.getNodeName().startsWith("rdfs:comment")) {
                    System.out.println("Description" + ": " + tempNode.getTextContent());
                } else if (tempNode.getNodeName().startsWith("hasPotColumnNumberOverall")) {
                    System.out.println("Lane" + ": " + tempNode.getTextContent());
                } else if (tempNode.getNodeName().startsWith("hasPotPositionTray")) {
                    System.out.println("Position" + ": " + tempNode.getTextContent());
                } else if (tempNode.getNodeName().startsWith("hasValue")) {
                    //if 
                    //prevValue = Integer.parseInt(tempNode.getNodeValue());
                } else {
                    System.out.println(tempNode.getNodeName() + ": " + tempNode.getTextContent());
                }//from w w w.  java 2s  .co m

            }

            if (tempNode.hasChildNodes()) {
                // loop again if has child node

                printNote(tempNode.getChildNodes());
                System.out.println("");

            }

        }

    }
}

From source file:de.ingrid.iplug.opensearch.converter.IngridRSSConverter.java

/**
 * Get the total number of hits./*from   w ww .ja va2  s. c o m*/
 * 
 * @param doc
 * @return
 * @throws XPathExpressionException
 */
private int getTotalResults(Document doc) throws XPathExpressionException {
    XPath xpath = XPathFactory.newInstance().newXPath();
    Node node = (Node) xpath.evaluate("/rss/channel/totalResults", doc, XPathConstants.NODE);
    if (node.getTextContent() == "") {
        return 0;
    } else {
        return Integer.valueOf(node.getTextContent());
    }
}

From source file:edu.cornell.mannlib.vitro.utilities.containerneutral.CheckContainerNeutrality.java

private void checkDispatcherValues() {
    List<String> okValues = Arrays.asList(new String[] { "FORWARD", "REQUEST", "INCLUDE", "ERROR" });
    for (Node n : findNodes("//j2ee:dispatcher")) {
        String text = n.getTextContent();
        if (!okValues.contains(text)) {
            messages.add(//from   w w w  .j ava2  s.c o m
                    "<dispatcher>" + text + "</dispatcher> is not valid. Acceptable values are " + okValues);
        }
    }
}

From source file:me.willowcheng.makerthings.model.OpenHABSitemapPage.java

public OpenHABSitemapPage(Document document) {
    Node rootNode = document.getFirstChild();
    if (rootNode == null)
        return;// w ww .  j  a va 2 s  .com
    mRootWidget = new OpenHABWidget();
    mRootWidget.setType("root");
    if (rootNode.hasChildNodes()) {
        NodeList childNodes = rootNode.getChildNodes();
        for (int i = 0; i < childNodes.getLength(); i++) {
            Node childNode = childNodes.item(i);
            if (childNode.getNodeName().equals("widget")) {
                OpenHABWidget newOpenHABWidget = new OpenHABWidget(mRootWidget, childNode);
                mWidgets.add(newOpenHABWidget);
            } else if (childNode.getNodeName().equals("title")) {
                this.setTitle(childNode.getTextContent());
            } else if (childNode.getNodeName().equals("id")) {
                this.setPageId(childNode.getTextContent());
            } else if (childNode.getNodeName().equals("icon")) {
                this.setIcon(childNode.getTextContent());
            } else if (childNode.getNodeName().equals("link")) {
                this.setLink(childNode.getTextContent());
            }
        }
    }

}

From source file:eu.esdihumboldt.hale.io.geoserver.rest.ResourceManagerIT.java

@Test
public void testConfigArchiveUpload() throws Exception {
    // build mapping file resource
    ContentType contentType = DataStoreFile.ZIP_CONTENT_TYPE;
    InputStream is = getClass().getResourceAsStream(APP_SCHEMA_CONFIG_ARCHIVE);
    DataStoreFile configArchive = ResourceBuilder.dataStoreFile(is, contentType)
            .setAttribute(DataStoreFile.EXTENSION, "appschema").setAttribute(DataStoreFile.DATASTORE, ds.name())
            .setAttribute(DataStoreFile.WORKSPACE, ns.name()).build();
    DataStoreFileManager dsFileMgr = new DataStoreFileManager(geoserverURL);
    dsFileMgr.setCredentials(GEOSERVER_USER, GEOSERVER_PASSWORD);
    dsFileMgr.setResource(configArchive);

    // upload mapping configuration (datastore is created implicitly)
    Map<String, String> updateParams = new HashMap<String, String>();
    updateParams.put("configure", "all");
    dsFileMgr.update(updateParams);/*from   w  w  w  . j  ava 2s  .c  om*/

    // verify datastore was created
    DataStoreManager dsMgr = createDataStoreManager();
    Document listDoc = dsMgr.list();
    assertEquals("dataStores", listDoc.getDocumentElement().getNodeName());

    NodeList dataStoreNodes = listDoc.getElementsByTagName("dataStore");
    assertEquals(1, dataStoreNodes.getLength());

    NodeList dataStoreChildren = dataStoreNodes.item(0).getChildNodes();
    for (int i = 0; i < dataStoreChildren.getLength(); i++) {
        Node child = dataStoreChildren.item(i);
        if ("name".equals(child.getNodeName())) {
            assertEquals(APP_SCHEMA_DATASTORE, child.getTextContent());
            break;
        }
    }

    // check feature types were created
    FeatureType lcd = ResourceBuilder.featureType("LandCoverDataset").build();
    FeatureType lcu = ResourceBuilder.featureType("LandCoverUnit").build();
    FeatureTypeManager ftMgr = new FeatureTypeManager(geoserverURL);
    ftMgr.setCredentials(GEOSERVER_USER, GEOSERVER_PASSWORD);
    ftMgr.setWorkspace(ns.name());
    ftMgr.setDataStore(ds.name());

    ftMgr.setResource(lcd);
    assertTrue(ftMgr.exists());

    ftMgr.setResource(lcu);
    assertTrue(ftMgr.exists());
}