Package org.w3c.dom.traversal

Examples of org.w3c.dom.traversal.NodeIterator


    String [] parts = value.split("[,]");

    String hash = dexter.getIdHash();

    DocumentTraversal tr = (DocumentTraversal)document;
    NodeIterator it = tr.createNodeIterator(
        element, NodeFilter.FILTER_ACCEPT,
        new JsTagFilter(), false);
    Element el;
    while((el = (Element)it.nextNode()) != null) {
      String path = el.getAttribute("src");
      int n = path.lastIndexOf('.');
      if(n > -1) {
        String base = path.substring(0,n);
        el.setAttribute("src", base + '@' + hash + path.substring(n));
      }
    }

     it = tr.createNodeIterator(
          element, NodeFilter.FILTER_ACCEPT,
          new CssTagFilter(), false);
    while((el = (Element)it.nextNode()) != null) {
      String path = el.getAttribute("href");
      int n = path.lastIndexOf('.');
      if(n > -1) {
        String base = path.substring(0,n);
        el.setAttribute("href", base + '@' + hash + path.substring(n));
View Full Code Here


  public void edit(String namespace, String name, String value)
  {
    String dexterity = DexterityConstants.BASE_NAMESPACE;

    DocumentTraversal tr = (DocumentTraversal)document;
    NodeIterator it = tr.createNodeIterator(
        element, NodeFilter.FILTER_ACCEPT,
        new InputFilter(), false);
    Element e;
    String[] ns = dexter.namespaces();
    while((e = (Element)it.nextNode()) != null) {
      NamedNodeMap attr = e.getAttributes();
      if(! usesNamespace(attr,ns)) {
        Node nn = attr.getNamedItem("name");
        if(nn == null) {
          System.err.println("WARNING: form element has no name");
View Full Code Here

      DocumentBuilder builder = dbf.newDocumentBuilder();
      // builder.
      Document impl = builder.parse(new FileInputStream(f));
      DocumentTraversal traversal = (DocumentTraversal) impl;

      NodeIterator nit = traversal.createNodeIterator(impl,
            NodeFilter.FILTER_ACCEPT, new PathNodeFilter(path), false);

      int counter = 0;
      while (nit.nextNode() != null)
      {
        ++counter;
      }
      System.out.println("found " + counter + " nodes for path " + args[1]);
View Full Code Here

    try {
      int removedSelNum = removed != null ? removed.length : 0;
      int addedSelNum = added != null ? added.length : 0;

      NodeIterator iter = ((DocumentTraversal) doc).createNodeIterator(doc, NodeFilter.SHOW_ELEMENT, null, true);
      Node node;
      while ((node = iter.nextNode()) != null) {
        if (node.getNodeType() == Node.ELEMENT_NODE) {
          Element elm = (Element) node;
          boolean match = false;
          int i;
          for (i = 0; i < removedSelNum && !match; i++) {
View Full Code Here

      return new NodeListImpl();

    DocumentImpl document = (DocumentImpl) getOwnerDocument();
    if (document == null)
      return new NodeListImpl();
    NodeIterator it = document.createNodeIterator(this, NodeFilter.SHOW_ALL, null, false);
    if (it == null)
      return new NodeListImpl();
    NodeListImpl elements = new NodeListImpl();

    if (tagName.length() == 1 && tagName.charAt(0) == '*') {
      tagName = null; // do not care
    }

    it.nextNode(); // skip the first node since it is the root from createNodeIterator
    for (Node node = it.nextNode(); node != null; node = it.nextNode()) {
      if (node.getNodeType() != ELEMENT_NODE)
        continue;
      if (tagName != null) {
        ElementImpl element = (ElementImpl) node;
        if (!element.matchTagName(tagName))
View Full Code Here

      return new NodeListImpl();

    DocumentImpl document = (DocumentImpl) getOwnerDocument();
    if (document == null)
      return new NodeListImpl();
    NodeIterator it = document.createNodeIterator(this, NodeFilter.SHOW_ALL, null, false);
    if (it == null)
      return new NodeListImpl();
    NodeListImpl elements = new NodeListImpl();

    if (uri != null && uri.length() == 1 && uri.charAt(0) == '*') {
      uri = null; // do not care
    }
    if (tagName.length() == 1 && tagName.charAt(0) == '*') {
      tagName = null; // do not care
    }

    it.nextNode(); // skip the first node since it is the root from createNodeIterator
    for (Node node = it.nextNode(); node != null; node = it.nextNode()) {
      if (node.getNodeType() != ELEMENT_NODE)
        continue;
      ElementImpl element = (ElementImpl) node;
      if (tagName != null) {
        String localName = element.getLocalName();
View Full Code Here

            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

        assertEquals(headerCount, 2);
    }

    protected void checkUserIdNamespace(Node node) throws Exception {
        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

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

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.