Package org.w3c.dom.traversal

Examples of org.w3c.dom.traversal.NodeIterator


   public Node selectSingleNode(
           Node contextNode, Node xpathnode, Node namespaceNode)
              throws TransformerException {

      // Have the XObject return its result as a NodeSetDTM.
      NodeIterator nl = selectNodeIterator(contextNode, xpathnode,
                                           namespaceNode);

      // Return the first node, or null
      return nl.nextNode();
   }
View Full Code Here


            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

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

      serializer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");

      // Use the simple XPath API to select a nodeIterator.
      // System.out.println("Querying DOM using " + xpath);
      NodeIterator nl = XPathAPI.selectNodeIterator(doc, xpath);

      // Serialize the found nodes to System.out.
      // System.out.println("<output>");
      String[] nodeTypeString = new String[]{ "", "ELEMENT", "ATTRIBUTE",
                                              "TEXT_NODE", "CDATA_SECTION",
                                              "ENTITY_REFERENCE", "ENTITY",
                                              "PROCESSING_INSTRUCTION",
                                              "COMMENT", "DOCUMENT",
                                              "DOCUMENT_TYPE",
                                              "DOCUMENT_FRAGMENT", "NOTATION" };
      int i = 0;
      Node n;

      while ((n = nl.nextNode()) != null) {

         // System.out.println("<node" + ++i + " nodeType=\"" + nodeTypeString[n.getNodeType()] + "\">");
         // serializer.transform(new DOMSource(n), new StreamResult(System.out));
         // System.out.println("</node" + i + ">");
         // System.out.println();
View Full Code Here

   public Node selectSingleNode(
           Node contextNode, Node xpathnode, Node namespaceNode)
              throws TransformerException {

      // Have the XObject return its result as a NodeSetDTM.
      NodeIterator nl = selectNodeIterator(contextNode, xpathnode,
                                           namespaceNode);

      // Return the first node, or null
      return nl.nextNode();
   }
View Full Code Here

   public static Node selectSingleNode(
           Node contextNode, Node xpathnode, Node namespaceNode)
              throws TransformerException {

      // Have the XObject return its result as a NodeSetDTM.
      NodeIterator nl = selectNodeIterator(contextNode, xpathnode,
                                           namespaceNode);

      // Return the first node, or null
      return nl.nextNode();
   }
View Full Code Here

      Transformer serializer = TransformerFactory.newInstance().newTransformer();
      serializer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");

      // Use the simple XPath API to select a nodeIterator.
      System.out.println("Querying DOM using "+xpath);
      NodeIterator nl = XPathAPI.selectNodeIterator(doc, xpath);

      // Serialize the found nodes to System.out.
      System.out.println("<output>");
                 
      Node n;
      while ((n = nl.nextNode())!= null)
      {        
  if (isTextNode(n)) {
      // DOM may have more than one node corresponding to a
      // single XPath text node.  Coalesce all contiguous text nodes
      // at this level
View Full Code Here

    public NodeIterator createNodeIterator(Node root,
                                           int whatToShow,
                                           NodeFilter filter,
                                           boolean entityReferenceExpansion)
    {
        NodeIterator iterator = new NodeIteratorImpl(this,
                                                     root,
                                                     whatToShow,
                                                     filter,
                                                     entityReferenceExpansion);
        if (iterators == null) {
View Full Code Here

        if ( returnType.equals( XPathConstants.NODESET ) ) {
            return resultObject.nodelist();
        }
        // XPathConstants.NODE
        if ( returnType.equals( XPathConstants.NODE ) ) {
            NodeIterator ni = resultObject.nodeset();
            //Return the first node, or null
            return ni.nextNode();
        }
        // JSTLXPathConstants.OBJECT
        if ( returnType.equals( JSTLXPathConstants.OBJECT ) ) {
            if (resultObject instanceof com.sun.org.apache.xpath.internal.objects.XNodeSet)
                return resultObject.nodelist();
View Full Code Here

        return content;
    }
   
    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

TOP

Related Classes of org.w3c.dom.traversal.NodeIterator

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.