Package javax.xml.xpath

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


    // Now the XPath expression
    try {
      XPathFactory xpathFact = XPathFactory.newInstance();
      XPath xpath = xpathFact.newXPath();
      Boolean result = (Boolean) xpath.evaluate(booleanExpression, booleanExpression, XPathConstants.BOOLEAN);

      /*
       * Set control port to make execution flow continue according to
       * condition
       */
 
View Full Code Here


    private static NodeList queryNodes(Document metadata, String xpathQuery) {
        try {
            XPath xpath = XPATH_FACTORY.newXPath();
            xpath.setNamespaceContext(NAMESPACE_CONTEXT);
            return (NodeList) xpath.evaluate(xpathQuery, metadata, XPathConstants.NODESET);
        } catch (XPathExpressionException ex) {
            throw new RuntimeException("Error evaluating XPath: " + xpathQuery, ex);
        }
    }
View Full Code Here

    private static Node queryNode(Document metadata, String xpathQuery) {
        try {
            XPath xpath = XPATH_FACTORY.newXPath();
            xpath.setNamespaceContext(NAMESPACE_CONTEXT);
            return (Node) xpath.evaluate(xpathQuery, metadata, XPathConstants.NODE);
        } catch (XPathExpressionException ex) {
            throw new RuntimeException("Error evaluating XPath: " + xpathQuery, ex);
        }
    }
View Full Code Here

            }
            else {
                throw new IllegalArgumentException("Invalid parameter type [" + parameterTypes[i] + "]. " +
                        "Supported are: Boolean, Double, Node, NodeList, and String.");
            }
            args[i] = xpath.evaluate(expression, payloadElement, conversionType);
        }
        return args;
    }

    private synchronized XPath createXPath() {
View Full Code Here

        XPath xpath = createXPath();
        xpath.setNamespaceContext(NamespaceUtils.getNamespaceContext(parameter.getMethod()));

        Element rootElement = getRootElement(messageContext.getRequest().getPayloadSource());
        String expression = parameter.getParameterAnnotation(XPathParam.class).value();
        Object result = xpath.evaluate(expression, rootElement, evaluationReturnType);
        return useConversionService ? conversionService.convert(result, parameterType) : result;
    }

    private QName getReturnType(Class<?> parameterType) {
        if (Boolean.class.equals(parameterType) || Boolean.TYPE.equals(parameterType)) {
View Full Code Here

            throws ServletException, IOException {

        try {
            XPath xpath = XPathFactory.newInstance().newXPath();

            String result = xpath.evaluate("/content/name", new InputSource(new StringReader(XML_INPUT)));

            response.setContentType("text/plain");
            response.getWriter().write(result);
        } catch (XPathExpressionException e) {
            throw new ServletException(e.getMessage(), e);
View Full Code Here

    public NodeList getByXpath(String xpath) throws ParsingException {
        XPath path = XPathFactory.newInstance().newXPath();
        NodeList childNodes;
        try {
            childNodes = (NodeList) path.evaluate(xpath, xmlDocument, XPathConstants.NODESET);
        } catch (XPathExpressionException e) {
            throw new ParsingException("Error evaluate xpath", e);
        }
        return childNodes;
    }
View Full Code Here

                List<Node> nodeSet = new ArrayList<Node>();

                for (int i = 0; i < childNodes.getLength(); i++) {
                    Node node = childNodes.item(i).cloneNode(true);

                    String key = serializeNodes((NodeList) path.evaluate(keyXPath, node, XPathConstants.NODESET));
                    if (!keySet.contains(key)) {
                        keySet.add(key);
                        nodeSet.add(node);
                    }
                }
View Full Code Here

      // in the current case though, the stream is valid so we wont load the resource by name
      Config schemaConf = new Config(loader, "schema", is, "/schema/");
      Document document = schemaConf.getDocument();
      final XPath xpath = schemaConf.getXPath();
      final List<SchemaAware> schemaAware = new ArrayList<SchemaAware>();
      Node nd = (Node) xpath.evaluate("/schema/@name", document, XPathConstants.NODE);
      if (nd==null) {
        log.warn("schema has no name!");
      } else {
        name = nd.getNodeValue();
        log.info("Schema name=" + name);
View Full Code Here

        {
          FieldType ft = (FieldType)loader.newInstance(className);
          ft.setTypeName(name);

          String expression = "./analyzer[@type='query']";
          Node anode = (Node)xpath.evaluate(expression, node, XPathConstants.NODE);
          Analyzer queryAnalyzer = readAnalyzer(anode);

          // An analyzer without a type specified, or with type="index"
          expression = "./analyzer[not(@type)] | ./analyzer[@type='index']";
          anode = (Node)xpath.evaluate(expression, node, XPathConstants.NODE);
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.