Package javax.xml.xpath

Examples of javax.xml.xpath.XPathFactory.newXPath()


            CoverageScope scope) throws WSSecurityException {
       
        // XPathFactory and XPath are not thread-safe so we must recreate them
        // each request.
        final XPathFactory factory = XPathFactory.newInstance();
        final XPath xpath = factory.newXPath();
       
        if (namespaces != null) {
            xpath.setNamespaceContext(new MapNamespaceContext(namespaces));
        }
       
View Full Code Here


    }

    private Object eval( String expr, String document, QName returnType )
            throws XPathExpressionException {
        final XPathFactory factory = XPathFactory.newInstance();
        final javax.xml.xpath.XPath xpath = factory.newXPath();
        return xpath.evaluate( expr, source( document ), returnType );
    }

    private InputSource source( String xml ) {
        return new InputSource( new StringReader( xml ) );
View Full Code Here

      // evaluate XPath expressions which are stored in xpathList
      // and save result nodes in queryList
      for (int j = 0; j < this.xpathList.size(); j++) {
        XPathFactory factory = XPathFactory.newInstance();
        XPath xpath = factory.newXPath();
        XPathExpression expr = xpath.compile(this.xpathList.get(j));
        Object results = expr.evaluate(doc, XPathConstants.NODESET);
        NodeList nodes = (NodeList) results;
        queryList.add(nodes);
      }
View Full Code Here

            docBuilderFactory.setNamespaceAware( false );
            DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
            Document doc = docBuilder.parse(new ByteArrayInputStream(locationString.getBytes("UTF-8")));

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

            NodeList resultNodes = (NodeList) xpath.evaluate(
                //"/ResultSet/Result", doc, XPathConstants.NODESET
                                "/response/result/doc", doc, XPathConstants.NODESET
                                );
View Full Code Here

  /**
   * Apply an XPath query to an XML document.
   */
  public IterableElementList xpath(Node doc, String query) throws XPathExpressionException {
    XPathFactory factory = XPathFactory.newInstance();
    XPath xpath = factory.newXPath();
    XPathExpression expr = xpath.compile(query);
    NodeList result = (NodeList) expr.evaluate(doc, XPathConstants.NODESET);
    return new IterableElementList(result);
  }
 
View Full Code Here

            domFactory.setNamespaceAware(true); // never forget this!
            DocumentBuilder builder = domFactory.newDocumentBuilder();
            Document doc = builder.parse(applicationConfigStream);

            XPathFactory factory = XPathFactory.newInstance();
            XPath xpath = factory.newXPath();
            XPathExpression expr = xpath.compile(RECENT_CONNECTIONS_FACTORIES_XPATH);

            Object result = expr.evaluate(doc, XPathConstants.NODESET);
            NodeList nodes = (NodeList) result;
            for (int i = 0; i < nodes.getLength(); i++) {
View Full Code Here

  /**
   * Apply an XPath query to an XML document.
   */
  public IterableElementList xpath(Node doc, String query) throws XPathExpressionException {
    XPathFactory factory = XPathFactory.newInstance();
    XPath xpath = factory.newXPath();
    XPathExpression expr = xpath.compile(query);
    NodeList result = (NodeList) expr.evaluate(doc, XPathConstants.NODESET);
    return new IterableElementList(result);
  }
 
View Full Code Here

                throw new RuntimeException("6th parameter has to be NodeList. It is " + namespaceContext.getClass().getName() + " value is " + namespaceContext.toString());
            }

            XPathFactory factory;
            factory = XPathFactory.newInstance( XPathFactory.DEFAULT_OBJECT_MODEL_URI );
            XPath xpath = factory.newXPath();

            /* custom xpath function resolver */
            xpath.setXPathFunctionResolver(new XPathFunctionResolverImpl());
            xpath.setXPathVariableResolver(new XPathVariableResolverImpl(order, orderName, orderLine, orderLineName, parameters, xpath));

View Full Code Here

    }

    private Node getNode(String xpath) throws IOException, SAXException, XPathExpressionException {
        Document order = YADOMUtil.parseStream(getClass().getResourceAsStream("ognl-test-01.xml"), false, false, true);
        XPathFactory xPathFactory = XPathFactory.newInstance();
        XPath xpathEvaluater = xPathFactory.newXPath();

        xpathEvaluater.setNamespaceContext(new MockNamespaceContext());

        return (Node) xpathEvaluater.evaluate(xpath, order, XPathConstants.NODE);       
    }
View Full Code Here

        Document document;
        Configuration config = new Configuration();
        try {
            document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(configFile);
            XPathFactory xpFactory = XPathFactory.newInstance();
            XPath xpath = xpFactory.newXPath();
            config.setDatabaseType(Integer.parseInt(xpath.evaluate("/config/database/type",document)));
            config.setDatabaseServerPath(xpath.evaluate("/config/database/serverPath",document));
            config.setDatabaseSchema(xpath.evaluate("/config/database/schema",document));
            config.setDatabaseUser(xpath.evaluate("/config/database/user",document));
            config.setDatabasePass(xpath.evaluate("/config/database/pass",document));
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.