Package org.w3c.dom.traversal

Examples of org.w3c.dom.traversal.NodeIterator


    Node parentNode = null;
    try{
      DocumentTraversal traversal = (DocumentTraversal)doc;
     
      CharSequence prefixChar = ":";
      NodeIterator iterator = traversal.createNodeIterator(document.getDocumentElement(), NodeFilter.SHOW_ELEMENT, null, true);
      for (Node n = iterator.nextNode(); n != null; n = iterator.nextNode()) {
        String nodeName = n.getNodeName();
        String[] str = null;
        if(n.getNodeName().contains(prefixChar)){
          str = nodeName.split(":");
          nodeName = str[str.length-1];
View Full Code Here


     *  nodes instead
     * @exception NodeTestException if test fails
     */
    public void performTest(NodeTester tester, short[] nodeTypes)
        throws NodeTestException {
        NodeIterator iter = documentTraversal.createNodeIterator(rootNode,
                                                                 NodeFilter.SHOW_ALL, new NodeTypeNodeFilter(nodeTypes), true);

        for (Node nextNode = iter.nextNode(); nextNode != null;
             nextNode = iter.nextNode()) {
            tester.testNode(nextNode, this);
        }
        tester.noMoreNodes(this);
    }
View Full Code Here

        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

      {
         final XObject xobj = xobjs[i];

         if ( xobj.getType(  ) == XObject.CLASS_NODESET )
         {
            NodeIterator nodeIter = xobj.nodeset(  );

            for ( Node node = nodeIter.nextNode(  ); node != null; node = nodeIter.nextNode(  ) )
            {
               final Element elem = (Element) node;
               nodes.add( SaajUtils.toSOAPElement( elem ) );
            }
         }
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

            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

      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" };
      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

      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) {

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

        throws DOMException {
        if (root == null) {
            throw doc.createDOMException
                (DOMException.NOT_SUPPORTED_ERR, "null.root"null);
        }
        NodeIterator result = new DOMNodeIterator(doc, root, whatToShow,
                                                  filter,
                                                  entityReferenceExpansion);
        if (iterators == null) {
            iterators = new LinkedList();
        }
View Full Code Here

        XMLSerializer serializer = new XMLSerializer(output, format);
        serializer.serialize((Document) node);
        logger.info(output.toString());
       
        CachedXPathAPI cachedXPathAPI = new CachedXPathAPI();
        NodeIterator iterator = cachedXPathAPI.selectNodeIterator(node, "//*[local-name() = 'userId']");
        Element root = (Element) iterator.nextNode();
        QName qname = DOMUtil.createQName(root, root.getAttributeNS("http://www.w3.org/2001/XMLSchema-instance", "type"));
        assertEquals("http://www.w3.org/2001/XMLSchema", qname.getNamespaceURI());
        assertEquals("string", qname.getLocalPart());
       
    }
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.