Package javax.xml.xpath

Examples of javax.xml.xpath.XPathExpression.evaluate()


            try {
                exp = XmlSignatureHelper.getXPathExpression(xp);
            } catch (XPathExpressionException e) {
                throw new XmlSignatureException("The parent XPath " + getConfiguration().getParentXpath().getXPath() + " is wrongly configured: The XPath " + xp.getXPath() + " is invalid.", e);
            }
            NodeList list = (NodeList) exp.evaluate(doc.getDocumentElement(), XPathConstants.NODESET);
            if (list == null || list.getLength() == 0) {
                throw new XmlSignatureException("The parent XPath " + xp.getXPath() + " returned no result. Check the configuration of the XML signer component.");
            }
            int length = list.getLength();
            for (int i = 0; i < length; i++) {
View Full Code Here


            try {
                exp = XmlSignatureHelper.getXPathExpression(xp);
            } catch (XPathExpressionException e) {
                throw new XmlSignatureException("The configured xpath expression " + xp.getXPath() + " is invalid.", e);
            }
            NodeList list = (NodeList) exp.evaluate(messageBodyNode, XPathConstants.NODESET);
            if (list == null) {
                //assume optional element, XSD validation has been done before
                LOG.warn("No ID attribute found for xpath expression {}. Therfore this xpath expression will be ignored.", xp.getXPath());
                continue;
            }
View Full Code Here

                return prefix2Namespace.get(prefix);
            }
        };
        xpath.setNamespaceContext(nc);
        XPathExpression expr = xpath.compile(xpathString);
        Object result = expr.evaluate(XmlSignatureHelper.newDocumentBuilder(true).parse(body), XPathConstants.NODE);
        assertNotNull("The xpath " + xpathString + " returned a null value", result);
        return result;
    }

    private Message getMessage(MockEndpoint mock) {
View Full Code Here

            public String getNamespaceURI(String prefix) {
                switch (prefix) {
                    case "scr":
                        try {
                            XPathExpression scrNamespace = xPath.compile("/*/namespace::*[name()='scr']");
                            Node node = (Node) scrNamespace.evaluate(dom, XPathConstants.NODE);
                            return node.getNodeValue();
                        } catch (XPathExpressionException e) {
                            // ignore
                            LOG.debug("Error evaluating xpath to obtain namespace prefix. This exception is ignored and using namespace: http://www.osgi.org/xmlns/scr/v1.1.0", e);

View Full Code Here

        XPathExpression propertyName = xPath.compile("@name");
        XPathExpression propertyValue = xPath.compile("@value");
        NodeList nodes = (NodeList) propertyList.evaluate(dom, XPathConstants.NODESET);
        for (int i = 0; i < nodes.getLength(); i++) {
            Node node = nodes.item(i);
            result.put((String) propertyName.evaluate(node, XPathConstants.STRING), (String) propertyValue.evaluate(node, XPathConstants.STRING));
        }
        return result;
    }

    private static Document readXML(File xml) throws Exception {
View Full Code Here

      try {
        XPathFactory xPathfactory = XPathFactory.newInstance();
        XPath xpath = xPathfactory.newXPath();
        XPathExpression expr = xpath
            .compile("/response/lst[@name='status']/lst/date[@name='startTime']/text()");
        return (String) expr.evaluate(dom, XPathConstants.STRING);
      } catch (XPathExpressionException e) {
        throw new OpsException("Error reading value from XML", e);
      }
    }
  }
View Full Code Here

    XPath xpath = factory.newXPath();
    Object result;
    try {
      XPathExpression expr =
        xpath.compile("/stratcon/database/dbconfig/" + param + "/text()");
      result = expr.evaluate(doc, XPathConstants.NODESET);
    }
    catch(XPathExpressionException e) {
      System.err.println("Bad expression: " + e.getMessage());
      return null;
    }
View Full Code Here

    XPath xpath = factory.newXPath();
    Object result;
    try {
      XPathExpression expr =
        xpath.compile("/stratcon/iep/broker/@adapter");
      result = expr.evaluate(doc, XPathConstants.NODESET);
    }
    catch(XPathExpressionException e) {
      System.err.println("Bad expression: " + e.getMessage());
      return null;
    }
View Full Code Here

    XPath xpath = factory.newXPath();
    Object result;
    try {
      XPathExpression expr =
        xpath.compile("/stratcon/iep/mq/@type");
      result = expr.evaluate(doc, XPathConstants.NODESET);
    }
    catch(XPathExpressionException e) {
      System.err.println("Bad expression: " + e.getMessage());
      return null;
    }
View Full Code Here

    XPath xpath = factory.newXPath();
    Object result;
    try {
      XPathExpression expr =
        xpath.compile("/stratcon/iep/" + which + "/" + param + "/text()");
      result = expr.evaluate(doc, XPathConstants.NODESET);
    }
    catch(XPathExpressionException e) {
      System.err.println("Bad expression: " + e.getMessage());
      return null;
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.