1 57 113 114 package org.enhydra.apache.html.dom; 115 116 import org.enhydra.apache.xerces.dom.DeepNodeListImpl; 117 import org.enhydra.apache.xerces.dom.ElementImpl; 118 import org.enhydra.apache.xerces.dom.NodeImpl; 119 import org.w3c.dom.Node ; 120 import org.w3c.dom.NodeList ; 121 122 130 public class NameNodeListImpl 131 extends DeepNodeListImpl 132 implements NodeList { 133 134 135 136 public NameNodeListImpl(NodeImpl rootNode, String tagName) { 137 super( rootNode, tagName ); 138 } 139 140 141 146 protected Node nextMatchingElementAfter(Node current) { 147 148 Node next; 149 while (current != null) { 150 if (current.hasChildNodes()) { 152 current = (current.getFirstChild()); 153 } 154 155 else if (current != rootNode && null != (next = current.getNextSibling())) { 157 current = next; 158 } 159 160 else { 162 next = null; 163 for (; current != rootNode; current = current.getParentNode()) { 165 166 next = current.getNextSibling(); 167 if (next != null) 168 break; 169 } 170 current = next; 171 } 172 173 if (current != rootNode && current != null 176 && current.getNodeType() == Node.ELEMENT_NODE ) { 177 String name = ((ElementImpl) current).getAttribute( "name" ); 178 if ( name.equals("*") || name.equals(tagName)) 179 return current; 180 } 181 182 } 184 185 return null; 187 188 } 190 } | Popular Tags |