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 893 public void setPrefix(String prefix) throws DOMException { 894 this.document.setPrefix(prefix); 895 } 896 897 900 public Node renameNode(Node node, String namespaceURI, String qualifiedName) throws DOMException { 901 throw new UnsupportedOperationException (DOMLEVEL3_ERR_MSG); 902 } 903 904 907 public void normalizeDocument() { 908 throw new UnsupportedOperationException (DOMLEVEL3_ERR_MSG); 909 } 910 911 914 public DOMConfiguration getDomConfig() { 915 throw new UnsupportedOperationException (DOMLEVEL3_ERR_MSG); 916 } 917 918 921 public Node adoptNode(Node source) { 922 throw new UnsupportedOperationException (DOMLEVEL3_ERR_MSG); 923 } 924 925 928 public void setDocumentURI(String uri) { 929 throw new UnsupportedOperationException (DOMLEVEL3_ERR_MSG); 930 } 931 932 935 public String getDocumentURI() { 936 throw new UnsupportedOperationException (DOMLEVEL3_ERR_MSG); 937 } 938 939 942 public void setStrictErrorChecking(boolean value) { 943 throw new UnsupportedOperationException (DOMLEVEL3_ERR_MSG); 944 } 945 946 949 public boolean getStrictErrorChecking() { 950 throw new UnsupportedOperationException (DOMLEVEL3_ERR_MSG); 951 } 952 953 956 public void setXmlVersion(String version) { 957 throw new UnsupportedOperationException (DOMLEVEL3_ERR_MSG); 958 } 959 960 963 public String getXmlVersion() { 964 throw new UnsupportedOperationException (DOMLEVEL3_ERR_MSG); 965 } 966 967 970 public void setXmlStandalone(boolean value) { 971 throw new UnsupportedOperationException (DOMLEVEL3_ERR_MSG); 972 } 973 974 977 public boolean getXmlStandalone() { 978 throw new UnsupportedOperationException (DOMLEVEL3_ERR_MSG); 979 } 980 981 984 public void setXmlEncoding(String version) { 985 throw new UnsupportedOperationException (DOMLEVEL3_ERR_MSG); 986 } 987 988 991 public String getXmlEncoding() { 992 throw new UnsupportedOperationException (DOMLEVEL3_ERR_MSG); 993 } 994 995 998 public String getInputEncoding() { 999 throw new UnsupportedOperationException (DOMLEVEL3_ERR_MSG); 1000 } 1001 1002 1005 public Object getUserData(String key) { 1006 throw new UnsupportedOperationException (DOMLEVEL3_ERR_MSG); 1007 } 1008 1009 1012 public Object setUserData(String key, Object value, UserDataHandler handler) { 1013 throw new UnsupportedOperationException (DOMLEVEL3_ERR_MSG); 1014 } 1015 1016 1019 public Object getFeature(String feature, String version) { 1020 throw new UnsupportedOperationException (DOMLEVEL3_ERR_MSG); 1021 } 1022 1023 1026 public short compareDocumentPosition(Node other) throws DOMException { 1027 throw new UnsupportedOperationException (DOMLEVEL3_ERR_MSG); 1028 } 1029 1030 1033 public String getBaseURI() { 1034 throw new UnsupportedOperationException (DOMLEVEL3_ERR_MSG); 1035 } 1036 1037 1040 public String getTextContent() throws DOMException { 1041 throw new UnsupportedOperationException (DOMLEVEL3_ERR_MSG); 1042 } 1043 1044 1047 public boolean isDefaultNamespace(String namespaceURI) { 1048 throw new UnsupportedOperationException (DOMLEVEL3_ERR_MSG); 1049 } 1050 1051 1054 public boolean isEqualNode(Node arg) { 1055 throw new UnsupportedOperationException (DOMLEVEL3_ERR_MSG); 1056 } 1057 1058 1061 public boolean isSameNode(Node other) { 1062 throw new UnsupportedOperationException (DOMLEVEL3_ERR_MSG); 1063 } 1064 1065 1068 public String lookupNamespaceURI(String prefix) { 1069 throw new UnsupportedOperationException (DOMLEVEL3_ERR_MSG); 1070 } 1071 1072 1075 public String lookupPrefix(String namespaceURI) { 1076 throw new UnsupportedOperationException (DOMLEVEL3_ERR_MSG); 1077 } 1078 1079 1082 public void setTextContent(String textContent) throws DOMException { 1083 throw new UnsupportedOperationException (DOMLEVEL3_ERR_MSG); 1084 } 1085} 1086 | Popular Tags |