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