Package org.apache.xpath

Examples of org.apache.xpath.CachedXPathAPI


            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
            factory.setNamespaceAware(true);
            DocumentBuilder dbuilder = factory.newDocumentBuilder();
            Document doc = dbuilder.parse(inputSource);
           
            CachedXPathAPI cachedXPathAPI = new CachedXPathAPI();
            NodeIterator iterator = cachedXPathAPI.selectNodeIterator(doc,xpath);
            return iterator.nextNode()!=null;
           
        } catch (Throwable e) {
            return false;
        }
View Full Code Here


            DocumentBuilder dbuilder = factory.newDocumentBuilder();
            Document doc = dbuilder.parse(inputSource);
           
            // We should associated the cachedXPathAPI object with the message being evaluated
            // since that should speedup subsequent xpath expressions.
            CachedXPathAPI cachedXPathAPI = new CachedXPathAPI();
            NodeIterator iterator = cachedXPathAPI.selectNodeIterator(doc,xpath);
            return iterator.nextNode()!=null;
        } catch (Throwable e) {
            return false;
        }
    }
View Full Code Here

      dbf.setNamespaceAware(true);

      javax.xml.parsers.DocumentBuilder db = dbf.newDocumentBuilder();
      org.w3c.dom.Document doc = db.parse(new FileInputStream(signatureFile));
      String BaseURI = signatureFile.toURL().toString();
      CachedXPathAPI xpathAPI = new CachedXPathAPI();
      Element nsctx = doc.createElement("nsctx");

      nsctx.setAttribute("xmlns:ds", Constants.SignatureSpecNS);

      Element signatureElem = (Element) xpathAPI.selectSingleNode(doc,
                                 "//ds:Signature", nsctx);
      XMLSignature sig = new XMLSignature(signatureElem, BaseURI);
      boolean verify = sig.checkSignatureValue(sig.getKeyInfo().getPublicKey());

      System.out.println("The signature is" + (verify
View Full Code Here

            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
            factory.setNamespaceAware(true);
            DocumentBuilder dbuilder = factory.newDocumentBuilder();
            Document doc = dbuilder.parse(inputSource);
           
            CachedXPathAPI cachedXPathAPI = new CachedXPathAPI();
            XObject result = cachedXPathAPI.eval(doc, xpath);
            if (result.bool())
              return true;
            else {
              NodeIterator iterator = cachedXPathAPI.selectNodeIterator(doc, xpath);
              return (iterator.nextNode() != null);
           

        } catch (Throwable e) {
            return false;
View Full Code Here

            //An XPath expression could return a true or false value instead of a node.
            //eval() is a better way to determine the boolean value of the exp.
            //For compliance with legacy behavior where selecting an empty node returns true,
            //selectNodeIterator is attempted in case of a failure.
           
            CachedXPathAPI cachedXPathAPI = new CachedXPathAPI();
            XObject result = cachedXPathAPI.eval(doc, xpath);
            if (result.bool())
              return true;
            else {
              NodeIterator iterator = cachedXPathAPI.selectNodeIterator(doc, xpath);
              return (iterator.nextNode() != null);
            }     
           
        } catch (Throwable e) {
            return false;
View Full Code Here

     * @param xpath
     * @return
     * @throws TransformerException
     */
    protected String textValueOfXPath(Node node, String xpath) throws TransformerException {
        CachedXPathAPI cachedXPathAPI = new CachedXPathAPI();
        NodeIterator iterator = cachedXPathAPI.selectNodeIterator(node, xpath);
        Node root = iterator.nextNode();
        if (root instanceof Element) {
            Element element = (Element) root;
            if (element == null) {
                return "";
View Full Code Here

            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
            factory.setNamespaceAware(true);
            DocumentBuilder dbuilder = factory.newDocumentBuilder();
            Document doc = dbuilder.parse(inputSource);
           
            CachedXPathAPI cachedXPathAPI = new CachedXPathAPI();
            XObject result = cachedXPathAPI.eval(doc, xpath);
            if (result.bool())
              return true;
            else {
              NodeIterator iterator = cachedXPathAPI.selectNodeIterator(doc, xpath);
              return (iterator.nextNode() != null);
           

        } catch (Throwable e) {
            return false;
View Full Code Here

            //An XPath expression could return a true or false value instead of a node.
            //eval() is a better way to determine the boolean value of the exp.
            //For compliance with legacy behavior where selecting an empty node returns true,
            //selectNodeIterator is attempted in case of a failure.
           
            CachedXPathAPI cachedXPathAPI = new CachedXPathAPI();
            XObject result = cachedXPathAPI.eval(doc, xpath);
            if (result.bool())
              return true;
            else {
              NodeIterator iterator = cachedXPathAPI.selectNodeIterator(doc, xpath);
              return (iterator.nextNode() != null);
            }     
           
        } catch (Throwable e) {
            return false;
View Full Code Here

        try
            {
            DOMSource inMessageXml = (DOMSource)sourceTransformer.toDOMSource(msg.getContent());

            // Parse out the actual message content
            CachedXPathAPI xpath = new CachedXPathAPI();
           
            Node exampleNode = xpath.selectSingleNode(inMessageXml.getNode(), "/example");
           
            if (exampleNode != null)
                {
                String value = exampleNode.getTextContent();
                propertySet.setString("ExampleKey", value);
View Full Code Here

        try {
            DOMSource inMessageXml = (DOMSource) sourceTransformer
                    .toDOMSource(msg.getContent());

            // Parse out the actual message content
            CachedXPathAPI xpath = new CachedXPathAPI();

            Node exampleNode = xpath.selectSingleNode(inMessageXml.getNode(),
                    "/example");

            if (exampleNode != null) {
                String value = exampleNode.getTextContent();
                logger.info("Received content: " + value);
View Full Code Here

TOP

Related Classes of org.apache.xpath.CachedXPathAPI

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.