Changeset 9977


Ignore:
Timestamp:
2005-05-26T16:20:45+12:00 (19 years ago)
Author:
kjdon
Message:

added a getNextNode method that doesn't print out stuff to a buffer - why did it do this anyway??

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/xpointer/XPointer.java

    r8456 r9977  
    107107      if (!close) {
    108108    to.append(node.getNodeValue());
     109    to.append(" ");
    109110      }
    110111    }
     
    114115    to.append(node.getNodeValue());
    115116    to.append(";");
     117    to.append(" ");
    116118      }
    117119    }
     
    161163  }
    162164
     165    public static Node getNextNode(Node currentNode) {
     166   
     167    // Try to get the first valid child
     168    NodeList children = currentNode.getChildNodes();
     169    for (int c = 0; c < children.getLength(); c++) {
     170        Node childNode = children.item(c);
     171       
     172        if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE ||
     173        childNode.getNodeType() == org.w3c.dom.Node.COMMENT_NODE ||
     174        childNode.getNodeType() == org.w3c.dom.Node.TEXT_NODE ||
     175        childNode.getNodeType() == org.w3c.dom.Node.ENTITY_NODE) {
     176        return childNode;
     177        }
     178    }   
     179   
     180    // now try a siblings and parents siblings
     181    Node siblingNode = null;
     182    do {
     183        siblingNode = currentNode.getNextSibling();
     184        if (siblingNode != null) {
     185        // should we be checking type??
     186        return siblingNode;
     187        }
     188       
     189        currentNode = currentNode.getParentNode();
     190    } while (currentNode != null);
     191   
     192    return null;
     193    }
     194
     195   
    163196  public static Node getNextNode(Node currentNode, StringBuffer buffer)
    164197  { Node reply;
     
    176209      }
    177210    }
    178 
     211   
    179212    // Repeat looking for a sibling & going up until done...
    180213    do {
Note: See TracChangeset for help on using the changeset viewer.