Package javax.xml.xpath

Examples of javax.xml.xpath.XPathFactory


      List<NodeList> queryList = new ArrayList<NodeList>();

      // 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


            DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
            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

            DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
            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

                    log.severe("6th parameter has to be NodeList. It is " + namespaceContext.getClass().getName() + " value is " + namespaceContext.toString());
                }
                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

      assertFalse( exists );
    }

    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

                    el = DOMUtils.getNextElement(el);
                }
            }
        }
        if (xpaths != null && !xpaths.isEmpty()) {
            XPathFactory factory = XPathFactory.newInstance();
            for (String expression : xpaths) {
                XPath xpath = factory.newXPath();
                if (namespaces != null) {
                    xpath.setNamespaceContext(new MapNamespaceContext(namespaces));
                }
                try {
                    NodeList list = (NodeList)xpath.evaluate(expression, saaj.getSOAPPart().getEnvelope(),
                                                   XPathConstants.NODESET);
                    for (int x = 0; x < list.getLength(); x++) {
                        Element el = (Element)list.item(x);
                        if (sign) {
                            WSEncryptionPart part = new WSEncryptionPart(el.getLocalName(),
                                                            el.getNamespaceURI(),
                                                            "Content",
                                                            WSConstants.PART_TYPE_ELEMENT);
                            part.setXpath(expression);
                            result.add(part);
                        } else {
                            WSEncryptionPart encryptedElem = new WSEncryptionPart(el.getLocalName(),
                                                                                  el.getNamespaceURI(),
                                                                                  "Element",
                                                                                  WSConstants
                                                                                      .PART_TYPE_ELEMENT);
                            encryptedElem.setXpath(expression);
                            String wsuId = el.getAttributeNS(WSConstants.WSU_NS, "Id");
                           
                            if (!StringUtils.isEmpty(wsuId)) {
                                encryptedElem.setEncId(wsuId);
                            }
                            result.add(encryptedElem);
                        }
                    }
                } catch (XPathExpressionException e) {
                    //REVISIT!!!!
                }
            }
        }
        if (contentXpaths != null && !contentXpaths.isEmpty()) {
            XPathFactory factory = XPathFactory.newInstance();
            for (String expression : contentXpaths) {
                XPath xpath = factory.newXPath();
                if (cnamespaces != null) {
                    xpath.setNamespaceContext(new MapNamespaceContext(cnamespaces));
                }
                try {
                    NodeList list = (NodeList)xpath.evaluate(expression, saaj.getSOAPPart().getEnvelope(),
View Full Code Here

                    SignedEncryptedElements p = (SignedEncryptedElements)ai.getAssertion();
                    namespaces = p.getDeclaredNamespaces();
                    xpaths = p.getXPathExpressions();
                }
                if (xpaths != null) {
                    XPathFactory factory = XPathFactory.newInstance();
                    for (String expression : xpaths) {
                        XPath xpath = factory.newXPath();
                        if (namespaces != null) {
                            xpath.setNamespaceContext(new MapNamespaceContext(namespaces));
                        }
                        try {
                            NodeList list = (NodeList)xpath.evaluate(expression,
View Full Code Here

TOP

Related Classes of javax.xml.xpath.XPathFactory

Copyright © 2018 www.massapicom. 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.