| 1 16 package org.apache.cocoon.xml.dom; 17 18 import org.apache.cocoon.ProcessingException; 19 import org.apache.cocoon.xml.XMLUtils; 20 21 import org.apache.excalibur.xml.sax.XMLizable; 22 23 import org.w3c.dom.Attr ; 24 import org.w3c.dom.CDATASection ; 25 import org.w3c.dom.Comment ; 26 import org.w3c.dom.DOMConfiguration ; 27 import org.w3c.dom.DOMException ; 28 import org.w3c.dom.DOMImplementation ; 29 import org.w3c.dom.Document ; 30 import org.w3c.dom.DocumentFragment ; 31 import org.w3c.dom.DocumentType ; 32 import org.w3c.dom.Element ; 33 import org.w3c.dom.EntityReference ; 34 import org.w3c.dom.NamedNodeMap ; 35 import org.w3c.dom.Node ; 36 import org.w3c.dom.NodeList ; 37 import org.w3c.dom.ProcessingInstruction ; 38 import org.w3c.dom.Text ; 39 import org.w3c.dom.UserDataHandler ; 40 import org.xml.sax.SAXException ; 41 42 43 50 public class DocumentWrapper implements org.w3c.dom.Document , XMLizable { 51 52 protected final static String DOMLEVEL3_ERR_MSG = 53 "This method was just added for providing future compatibility to JDK 1.5's DOM level 3 Document interface."; 54 55 protected final Document document; 56 57 58 public DocumentWrapper(Document doc) { 59 this.document = doc; 60 } 61 62 63 70 public void toSAX(org.xml.sax.ContentHandler handler) throws SAXException { 71 72 DOMStreamer ds = new DOMStreamer(handler); 73 ds.stream(this.document.getDocumentElement()); 74 } 75 76 77 public String toString() { 78 try { 79 return XMLUtils.serializeNode(this.document, XMLUtils.createPropertiesForXML(false)); 80 } catch (ProcessingException e) { 81 } 82 return ""; 83 } 84 85 86 104 public Node appendChild(Node newChild) throws DOMException { 105 return this.document.appendChild(newChild); 106 } 107 108 132 public Node cloneNode(boolean deep) { 133 return this.document.cloneNode(deep); 134 } 135 136 151 public Attr createAttribute(String name) throws DOMException { 152 return this.document.createAttribute(name); 153 } 154 155 217 public Attr createAttributeNS(String namespaceURI, String qualifiedName) throws DOMException { 218 return this.document.createAttributeNS(namespaceURI, qualifiedName); 219 } 220 221 229 public CDATASection createCDATASection(String data) throws DOMException { 230 return this.document.createCDATASection(data); 231 } 232 233 238 public Comment createComment(String data) { 239 return this.document.createComment(data); 240 } 241 242 246 public DocumentFragment createDocumentFragment() { 247 return this.document.createDocumentFragment(); 248 } 249 250 271 public Element createElement(String tagName) throws DOMException { 272 return this.document.createElement(tagName); 273 } 274 275 329 public Element createElementNS(String namespaceURI, String qualifiedName) throws DOMException { 330 return this.document.createElementNS(namespaceURI, qualifiedName); 331 } 332 333 350 public EntityReference createEntityReference(String name) throws DOMException { 351 return this.document.createEntityReference(name); 352 } 353 354 365 public ProcessingInstruction createProcessingInstruction(String target, String data) throws DOMException { 366 return this.document.createProcessingInstruction(target, data); 367 } 368 369 374 public Text createTextNode(String data) { 375 return this.document.createTextNode(data); 376 } 377 378 382 public NamedNodeMap getAttributes() { 383 return this.document.getAttributes(); 384 } 385 386 391 public NodeList getChildNodes() { 392 return this.document.getChildNodes(); 393 } 394 395 405 public DocumentType getDoctype() { 406 return this.document.getDoctype(); 407 } 408 409 414 public Element getDocumentElement() { 415 return this.document.getDocumentElement(); 416 } 417 418 431 public Element getElementById(String elementId) { 432 return this.document.getElementById(elementId); 433 } 434 435 444 public NodeList getElementsByTagName(String tagname) { 445 return this.document.getElementsByTagName(tagname); 446 } 447 448 460 public NodeList getElementsByTagNameNS(String namespaceURI, String localName) { 461 return this.document.getElementsByTagNameNS(namespaceURI, localName); 462 } 463 464 468 public Node getFirstChild() { 469 return this.document.getFirstChild(); 470 } 471 472 476 public DOMImplementation getImplementation() { 477 return this.document.getImplementation(); 478 } 479 480 484 public Node getLastChild() { 485 return this.document.getLastChild(); 486 } 487 488 496 public String getLocalName() { 497 return this.document.getLocalName(); 498 } 499 500 515 public String getNamespaceURI() { 516 return this.document.getNamespaceURI(); 517 } 518 519 523 public Node getNextSibling() { 524 return this.document.getNextSibling(); 525 } 526 527 530 public String getNodeName() { 531 return this.document.getNodeName(); 532 } 533 534 537 public short getNodeType() { 538 return this.document.getNodeType(); 539 } 540 541 550 public String getNodeValue() throws DOMException { 551 return this.document.getNodeValue(); 552 } 553 554 562 public Document getOwnerDocument() { 563 return this.document.getOwnerDocument(); 564 } 565 566 574 public Node getParentNode() { 575 return this.document.getParentNode(); 576 } 577 578 609 public String getPrefix() { 610 return this.document.getPrefix(); 611 } 612 613 617 public Node getPreviousSibling() { 618 return this.document.getPreviousSibling(); 619 } 620 621 627 public boolean hasAttributes() { 628 return this.document.hasAttributes(); 629 } 630 631 636 public boolean hasChildNodes() { 637 return this.document.hasChildNodes(); 638 } 639 640 738 public Node importNode(Node importedNode, boolean deep) throws DOMException { 739 return this.document.importNode(importedNode, deep); 740 } 741 742 766 public Node insertBefore(Node newChild, Node refChild) throws DOMException { 767 return this.document.insertBefore(newChild, refChild); 768 } 769 770 784 public boolean isSupported(String feature, String version) { 785 return this.document.isSupported(feature, version); 786 } 787 788 804 public void normalize() { 805 this.document.normalize(); 806 } 807 808 818 public Node removeChild(Node oldChild) throws DOMException { 819 return this.document.removeChild(oldChild); 820 } 821 822 845 public Node replaceChild(Node newChild, Node oldChild) throws DOMException { 846 return this.document.replaceChild(newChild, oldChild); 847 } 848 849 858 public void setNodeValue(String nodeValue) throws DOMException { 859 this.document.setNodeValue(nodeValue); 860 } 861 862 |