Package javax.xml.xpath

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


        try {
            TidyMarkupDataFormat dataFormat = new TidyMarkupDataFormat();
            dataFormat.setMethod("html");
            Node doc = dataFormat.asNodeTidyMarkup(IOHelper.buffered(url.openStream()));
            XPath xpath = XPathFactory.newInstance().newXPath();
            Node nd = (Node)xpath.evaluate("//div[@class='" + contentDivClass + "']", doc, XPathConstants.NODE);
            if (nd != null) {
                return  new XmlConverter().toString(nd, null);
            }
        } catch (Throwable e) {
            if (errorOnDownloadFailure) {
View Full Code Here


                    if (namespaces != null) {
                        xpath.setNamespaceContext(new MapNamespaceContext(namespaces));
                    }
                    NodeList list;
                    try {
                        list = (NodeList)xpath.evaluate(expression,
                                                                 header,
                                                                 XPathConstants.NODESET);
                        if (list.getLength() == 0) {
                            ai.setNotAsserted("No header element matching XPath " + expression + " found.");
                            return false;
View Full Code Here

     * @throws XPathExpressionException if the xpath query could not be executed
     */
    private boolean isCallSuccessful(String xmlResponse) throws XPathExpressionException {
        final XPath xpath = XPathFactory.newInstance().newXPath();

        final String exitCode = xpath.evaluate("/map/entry[@key = 'exit_code']/@value",
                new InputSource(new StringReader(xmlResponse)));

        return !(exitCode == null || !SUCCESS.equals(exitCode));

    }
View Full Code Here

     * @return true if call was successful, false otherwise
     * @throws XPathExpressionException if the xpath query could not be executed
     */
    private String getMessage(String xmlResponse) throws XPathExpressionException {
        final XPath xpath = XPathFactory.newInstance().newXPath();
        return xpath.evaluate("/map/entry[@key = 'message']/@value", new InputSource(new StringReader(xmlResponse)));
    }

    private ProtocolMetaData parseForProtocolMetaData(String xmlResponse) throws XPathExpressionException {
        final ProtocolMetaData protocolMetaData = new ProtocolMetaData();
        final HTTPContext httpContext = new HTTPContext(this.configuration.getRemoteServerAddress(),
View Full Code Here

        final HTTPContext httpContext = new HTTPContext(this.configuration.getRemoteServerAddress(),
                this.configuration.getRemoteServerHttpPort());

        final XPath xpath = XPathFactory.newInstance().newXPath();

        NodeList servlets = (NodeList) xpath.evaluate("/map/entry[@key = 'properties']/map/entry[@value = 'Servlet']",
                new InputSource(new StringReader(xmlResponse)), XPathConstants.NODESET);

        for (int i = 0; i < servlets.getLength(); i++) {
            httpContext.add(new Servlet(servlets.item(i).getAttributes().getNamedItem("key").getNodeValue(), this.deploymentName));
        }
View Full Code Here

      XPath xpath = XPathFactory.newInstance().newXPath();
      SimpleNamespaceContext nsContext = new SimpleNamespaceContext();
      nsContext.registerMapping("ad", archetypeDescriptorUri);
      xpath.setNamespaceContext(nsContext);

      NodeList properties = (NodeList) xpath.evaluate(requiredPropertyXPath, document, XPathConstants.NODESET);

      for (int p = 0; p < properties.getLength(); p++)
      {
         Element requiredProperty = (Element) properties.item(p);
View Full Code Here

  private static Element getTemplateRootNode(Document templateNode, String templateFragment) {
    try {
      XPath xpath = XPathFactory.newInstance().newXPath();
      Element documentElement = templateNode.getDocumentElement();
      if (templateFragment == null || templateFragment.trim().length() == 0) {
        return (Element) xpath.evaluate("//body", documentElement, XPathConstants.NODE);
      }
      else {
        return (Element) xpath.evaluate("//*[@data-field='" + templateFragment + "']", documentElement,
            XPathConstants.NODE);
      }
View Full Code Here

      Element documentElement = templateNode.getDocumentElement();
      if (templateFragment == null || templateFragment.trim().length() == 0) {
        return (Element) xpath.evaluate("//body", documentElement, XPathConstants.NODE);
      }
      else {
        return (Element) xpath.evaluate("//*[@data-field='" + templateFragment + "']", documentElement,
            XPathConstants.NODE);
      }
    }
    catch (XPathExpressionException e) {
      return null;
View Full Code Here

        XPath xpath = XPATH_FACTORY.newXPath();
        xpath.setNamespaceContext(jstlXPathNamespaceContext);
        xpath.setXPathVariableResolver(jxvr);
        try {
            return xpath.evaluate(xpathString, contextNode);
        } catch (XPathExpressionException ex) {
            throw new JspTagException(ex.toString(), ex);
        }
    }
   
View Full Code Here

       
        XPath xpath = XPATH_FACTORY.newXPath();
        xpath.setNamespaceContext(jstlXPathNamespaceContext);
        xpath.setXPathVariableResolver(jxvr);
        try {
            return ((Boolean) xpath.evaluate(
              xpathString, contextNode, XPathConstants.BOOLEAN)).booleanValue();
        } catch (XPathExpressionException ex) {
            throw new JspTagException(
                Resources.getMessage("XPATH_ERROR_XOBJECT", ex.toString()), ex);           
        }
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.