Package org.apache.xpath

Examples of org.apache.xpath.CachedXPathAPI


      Document doc = uri.getOwnerDocument();

      // this must be done so that Xalan can catch ALL namespaces
      XMLUtils.circumventBug2650(doc);

      CachedXPathAPI cXPathAPI = new CachedXPathAPI();

      if (uriNodeValue.equals("")) {

         /*
          * Identifies the node-set (minus any comment nodes) of the XML
          * resource containing the signature
          */

         // cat.debug("ResolverFragment with empty URI (means complete document)");
         try {
            resultNodes =
               cXPathAPI.selectNodeList(doc,
                                        Canonicalizer.XPATH_C14N_OMIT_COMMENTS);
         } catch (javax.xml.transform.TransformerException ex) {
            throw new ResourceResolverException("generic.EmptyMessage", ex,
                                                uri, BaseURI);
         }
      } else {

         /*
          * URI="#chapter1"
          * Identifies a node-set containing the element with ID attribute
          * value 'chapter1' of the XML resource containing the signature.
          * XML Signature (and its applications) modify this node-set to
          * include the element plus all descendents including namespaces and
          * attributes -- but not comments.
          */
         String id = uriNodeValue.substring(1);

         // Element selectedElem = doc.getElementById(id);
         Element selectedElem = IdResolver.getElementById(doc, id);

         // cat.debug("Try to catch an Element with ID " + id + " and Element was " + selectedElem);
         if (selectedElem == null) {
            resultNodes = new HelperNodeList();
         } else {
            try {
               resultNodes =
                  cXPathAPI
                     .selectNodeList(selectedElem, Canonicalizer
                        .XPATH_C14N_OMIT_COMMENTS_SINGLE_NODE);
            } catch (javax.xml.transform.TransformerException ex) {
               throw new ResourceResolverException("generic.EmptyMessage", ex,
                                                   uri, BaseURI);
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();

      XMLUtils.circumventBug2650(doc);

      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();

      if (writeResultsToFile) {
         File fileD = new File("defined.txt");
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

    * @return
    */
   public Enumeration aliases() {

      try {
         CachedXPathAPI xpath = new CachedXPathAPI();
         Element nsctx = this._doc.createElementNS(null, "nsctx");

         nsctx.setAttributeNS(Constants.NamespaceSpecNS, "xmlns:x",
                            ApacheKeyStoreConstants.ApacheKeyStore_NAMESPACE);

         NodeList aliasNodes =
            xpath.selectNodeList(this._doc,
                                 "/x:" + ApacheKeyStoreConstants._TAG_KEYSTORE
                                 + "/x:*/x:"
                                 + ApacheKeyStoreConstants._TAG_ALIAS
                                 + "/text()", nsctx);
         Vector result = new Vector(aliasNodes.getLength());
View Full Code Here

    * @return
    */
   public Element getCertificateEntryElement(String alias) {

      try {
         CachedXPathAPI xpath = new CachedXPathAPI();
         Element nsctx = this._doc.createElementNS(null, "nsctx");

         nsctx.setAttributeNS(Constants.NamespaceSpecNS, "xmlns:x",
                            ApacheKeyStoreConstants.ApacheKeyStore_NAMESPACE);

         String searchExpr = "/x:" + ApacheKeyStoreConstants._TAG_KEYSTORE
                             + "/x:" + ApacheKeyStoreConstants._TAG_CERTIFICATE
                             + "[./x:" + ApacheKeyStoreConstants._TAG_ALIAS
                             + "/text()=\"" + alias + "\"]";
         NodeList aliasNodes = xpath.selectNodeList(this._doc, searchExpr,
                                                    nsctx);

         if (aliasNodes.getLength() == 1) {
            return (Element) aliasNodes.item(0);
         }
View Full Code Here

    * @return
    */
   public Element getKeyEntryElement(String alias) {

      try {
         CachedXPathAPI xpath = new CachedXPathAPI();
         Element nsctx = this._doc.createElementNS(null, "nsctx");

         nsctx.setAttributeNS(Constants.NamespaceSpecNS, "xmlns:x",
                            ApacheKeyStoreConstants.ApacheKeyStore_NAMESPACE);

         String searchExpr = "/x:" + ApacheKeyStoreConstants._TAG_KEYSTORE
                             + "/x:" + ApacheKeyStoreConstants._TAG_KEY
                             + "[./x:" + ApacheKeyStoreConstants._TAG_ALIAS
                             + "/text()=\"" + alias + "\"]";
         NodeList aliasNodes = xpath.selectNodeList(this._doc, searchExpr,
                                                    nsctx);

         if (aliasNodes.getLength() == 1) {
            return (Element) aliasNodes.item(0);
         }
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

         .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'] | //@*)");
      byte result[] = c14nizer.canonicalizeXPathNodeSet(nodes);
      byte defined[] = definedOutput.getBytes();

      if (writeResultsToFile) {
         File fileD = new File("defined.txt");
View Full Code Here

                xpath += "/";

            xpath += "text()";
        }

        CachedXPathAPI xpathAPI = new CachedXPathAPI();
        Node foundNode = xpathAPI.selectSingleNode(document, xpath);

        if (foundNode == null)
            result = "";
        else if (foundNode.getNodeType() == Node.TEXT_NODE)
            result = ((Text)foundNode).getData();
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.