Package org.apache.xpath

Examples of org.apache.xpath.CachedXPathAPI


        assertEquals("http://www.w3.org/2001/XMLSchema", qname.getNamespaceURI());
        assertEquals("string", qname.getLocalPart());
  }
 
  protected void checkServiceNameNamespace(Node node) throws Exception {
        CachedXPathAPI cachedXPathAPI = new CachedXPathAPI();
        NodeIterator iterator = cachedXPathAPI.selectNodeIterator(node, "//*[local-name() = 'ServiceName']");
        Element root = (Element) iterator.nextNode();
        assertEquals(new QName("http://schemas.xmlsoap.org/ws/2003/03/addressing", "ServiceName"),
                 new QName(root.getNamespaceURI(), root.getLocalName()));
        QName qname = DOMUtil.createQName(root, DOMUtil.getElementText(root));
        assertEquals(new QName("uri:test", "MyConsumerService"), qname);
View Full Code Here


        //return ((int) (Math.random() * 19) + 1);
        return 10;
    }
   
    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

        // Wait all acks being processed
        Thread.sleep(100);
    }
   
    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();
            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

         + "self::ietf:e1 or "
         + "(parent::ietf:e1 and not(self::text() or self::e2)) or "
         + "count(id(\"E3\")|ancestor-or-self::node()) = count(ancestor-or-self::node()) "
         + "]";
      //J+
      CachedXPathAPI xpathAPI = new CachedXPathAPI();

      NodeList nodes = xpathAPI.selectNodeList(doc, xpath, nscontext);
      Canonicalizer c14n =
         Canonicalizer.getInstance(Canonicalizer.ALGO_ID_C14N_OMIT_COMMENTS);
      byte c14nBytes[] = c14n.canonicalizeXPathNodeSet(nodes);
      InputStream refStream = resolver.resolveEntity(null,
                                 fileRef).getByteStream();
View Full Code Here

         .IgnoreAllErrorHandler());

      Document doc = db.parse(new ByteArrayInputStream(input.getBytes()));
      Canonicalizer c14nizer =
         Canonicalizer.getInstance(Canonicalizer.ALGO_ID_C14N_OMIT_COMMENTS);
      CachedXPathAPI xpathAPI = new CachedXPathAPI();

      //XMLUtils.circumventBug2650(doc);

      NodeList nodes =
         xpathAPI.selectNodeList(doc, "(//*[local-name()='included'] | //@*[parent::node()[local-name()='included']])");
      byte result[] = c14nizer.canonicalizeXPathNodeSet(nodes);
      byte defined[] = definedOutput.getBytes();
      assertEquals(definedOutput, new String(result));
      return java.security.MessageDigest.isEqual(defined, result);
   }
View Full Code Here

      byte c14nBytes[] = null;

      if (xpath == null) {
         c14nBytes = c14n.canonicalizeSubtree(doc);
      } else {
         CachedXPathAPI xpathAPI = new CachedXPathAPI();
         NodeList nl = null;

         if (xpath instanceof String) {
            nl = xpathAPI.selectNodeList(doc, (String) xpath);
         } else {
            Element xpathElement = (Element) xpath;
            String xpathStr = ((Text) xpathElement.getFirstChild()).getData();

            nl = xpathAPI.selectNodeList(doc, xpathStr, xpathElement);
         }

         c14nBytes = c14n.canonicalizeXPathNodeSet(nl);
      }
View Full Code Here

         + "self::ietf:e1 or "
         + "(parent::ietf:e1 and not(self::text() or self::e2)) or "
         + "count(id(\"E3\")|ancestor-or-self::node()) = count(ancestor-or-self::node()) "
         + "]";
      //J+
      CachedXPathAPI xpathAPI = new CachedXPathAPI();

      NodeList nodes = xpathAPI.selectNodeList(doc, xpath, nscontext);
      Canonicalizer c14n =
         Canonicalizer.getInstance(Canonicalizer.ALGO_ID_C14N_OMIT_COMMENTS);
      byte c14nBytes[] = c14n.canonicalizeXPathNodeSet(nodes);
      InputStream refStream = resolver.resolveEntity(null,
                                 fileRef).getByteStream();
View Full Code Here

         .IgnoreAllErrorHandler());

      Document doc = db.parse(new ByteArrayInputStream(input.getBytes()));
      Canonicalizer c14nizer =
         Canonicalizer.getInstance(Canonicalizer.ALGO_ID_C14N_OMIT_COMMENTS);
      CachedXPathAPI xpathAPI = new CachedXPathAPI();

      //XMLUtils.circumventBug2650(doc);

      NodeList nodes =
         xpathAPI.selectNodeList(doc, "(//*[local-name()='included'] | //@*[parent::node()[local-name()='included']])");
      byte result[] = c14nizer.canonicalizeXPathNodeSet(nodes);
      byte defined[] = definedOutput.getBytes();
      assertEquals(definedOutput, new String(result));
      return java.security.MessageDigest.isEqual(defined, result);
   }
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.