1 package net.sf.saxon.dom; 2 3 import net.sf.saxon.om.Axis; 4 import net.sf.saxon.om.AxisIterator; 5 import net.sf.saxon.om.DocumentInfo; 6 import net.sf.saxon.om.NodeInfo; 7 import net.sf.saxon.type.Type; 8 import org.w3c.dom.*; 9 10 import java.util.ArrayList ; 11 12 16 17 public class DocumentOverNodeInfo extends NodeOverNodeInfo implements Document { 18 19 27 28 public DocumentType getDoctype() { 29 return null; 30 } 31 32 37 38 public DOMImplementation getImplementation() { 39 return new DOMImplementationImpl(); 40 } 41 42 46 47 public Element createElement(String tagName) throws DOMException { 48 disallowUpdate(); 49 return null; 50 } 51 52 57 58 public DocumentFragment createDocumentFragment() { 59 return null; 60 } 61 62 68 69 public Text createTextNode(String data) { 70 return null; 71 } 72 73 79 public Comment createComment(String data) { 80 return null; 81 } 82 83 92 93 public CDATASection createCDATASection(String data) throws DOMException { 94 disallowUpdate(); 95 return null; 96 } 97 98 110 111 public ProcessingInstruction createProcessingInstruction(String target, 112 String data) 113 throws DOMException { 114 disallowUpdate(); 115 return null; 116 } 117 118 130 131 public Attr createAttribute(String name) throws DOMException { 132 disallowUpdate(); 133 return null; 134 } 135 136 146 147 public EntityReference createEntityReference(String name) throws DOMException { 148 disallowUpdate(); 149 return null; 150 } 151 152 161 162 public NodeList getElementsByTagName(String tagname) { 163 return getElementsByTagName(node, tagname); 164 } 165 166 protected static NodeList getElementsByTagName(NodeInfo node, String tagname) { 167 AxisIterator allElements = node.iterateAxis(Axis.DESCENDANT); 168 ArrayList nodes = new ArrayList (100); 169 while(true) { 170 NodeInfo next = (NodeInfo)allElements.next(); 171 if (next == null) { 172 break; 173 } 174 if (next.getNodeKind()==Type.ELEMENT) { 175 if (tagname.equals("*") || tagname.equals(next.getDisplayName())) { 176 nodes.add(NodeOverNodeInfo.wrap(next)); 177 } 178 } 179 } 180 return new DOMNodeList(nodes); 181 } 182 183 184 190 191 public Node importNode(Node importedNode, boolean deep) throws DOMException { 192 disallowUpdate(); 193 return null; 194 } 195 196 206 207 public Element createElementNS(String namespaceURI, 208 String qualifiedName) 209 throws DOMException 210 { 211 disallowUpdate(); 212 return null; 213 } 214 215 225 226 public Attr createAttributeNS(String namespaceURI, 227 String qualifiedName) 228 throws DOMException { 229 disallowUpdate(); 230 return null; 231 } 232 233 246 247 public NodeList getElementsByTagNameNS(String namespaceURI, String localName) { 248 return getElementsByTagNameNS(node, namespaceURI, localName); 249 } 250 251 public static NodeList getElementsByTagNameNS(NodeInfo node, String namespaceURI, String localName) { 252 AxisIterator allElements = node.iterateAxis(Axis.DESCENDANT); 253 ArrayList nodes = new ArrayList (100); 254 while(true) { 255 NodeInfo next = (NodeInfo)allElements.next(); 256 if (next == null) { 257 break; 258 } 259 if (next.getNodeKind()==Type.ELEMENT) { 260 if ((namespaceURI.equals("*") || namespaceURI.equals(next.getURI())) && 261 (localName.equals("*") || localName.equals(next.getLocalPart()))) { 262 nodes.add(NodeOverNodeInfo.wrap(next)); 263 } 264 } 265 } 266 return new DOMNodeList(nodes); 267 } 268 269 282 283 public Element getElementById(String elementId) { 284 DocumentInfo doc = node.getDocumentRoot(); 286 if (doc == null) { 287 return null; 288 } 289 return (Element)wrap(doc.selectID(elementId)); 290 } 291 292 299 public String getInputEncoding() { 300 return null; 301 } 302 303 312 public String getXmlEncoding() { 313 return null; 314 } 315 316 329 public boolean getXmlStandalone() { 330 return false; 331 } 332 333 346 public void setXmlStandalone(boolean xmlStandalone) throws DOMException { 347 disallowUpdate(); 348 } 349 350 375 public String getXmlVersion() { 376 return "1.0"; 377 } 378 379 407 public void setXmlVersion(String xmlVersion) throws DOMException { 408 disallowUpdate(); 409 } 410 411 422 public boolean getStrictErrorChecking() { 423 return false; 424 } 425 426 437 public void setStrictErrorChecking(boolean strictErrorChecking) { 438 } 440 441 455 public String getDocumentURI() { 456 return node.getSystemId(); 457 } 458 459 473 public void setDocumentURI(String documentURI) { 474 disallowUpdate(); 475 } 476 477 546 public Node adoptNode(Node source) throws DOMException { 547 disallowUpdate(); 548 return null; 549 } 550 551 557 public DOMConfiguration getDomConfig() { 558 return null; 559 } 560 561 594 public void normalizeDocument() { 595 disallowUpdate(); 596 } 597 598 609 public Node renameNode(Node n, String namespaceURI, String qualifiedName) throws DOMException { 610 disallowUpdate(); 611 return null; 612 } 613 614 615 } 616 617 | Popular Tags |