88 try { 89 final DocumentBuilder documentBuilder = docFactory.newDocumentBuilder(); 90 return documentBuilder.newDocument(); 91 } catch (ParserConfigurationException e) { 92 throw new RuntimeException("Error creating xml document", e); 93 } 94 } 95 96 // public SOAPDocumentImpl(boolean grammarAccess) { 97 // super(grammarAccess); 98 // } 99 // 100 // public SOAPDocumentImpl(DocumentType doctype) { 101 // super(doctype); 102 // } 103 // 104 // public SOAPDocumentImpl(DocumentType doctype, boolean grammarAccess) { 105 // super(doctype, grammarAccess); 106 // } 107 108 public SOAPPartImpl getSOAPPart() { 109 if (enclosingSOAPPart == null) { 110 log.severe("SAAJ0541.soap.fragment.not.bound.to.part"); 111 throw new RuntimeException("Could not complete operation. Fragment not bound to SOAP part."); 112 } 113 return enclosingSOAPPart; 114 } 115 116 public SOAPDocumentImpl getDocument() { 117 return this; 118 } 119 120 public DocumentType getDoctype() { 121 // SOAP means no DTD, No DTD means no doctype (SOAP 1.2 only?) 122 return null; 123 } 124 125 public DOMImplementation getImplementation() { 126 return document.getImplementation(); 127 } 128 129 public Element getDocumentElement() { 130 // This had better be an Envelope! 131 getSOAPPart().doGetDocumentElement(); 132 return doGetDocumentElement(); 133 } 134 135 protected Element doGetDocumentElement() { 136 return document.getDocumentElement(); 137 } 138 139 public Element createElement(String tagName) throws DOMException { 140 return ElementFactory.createElement( 141 this, 142 NameImpl.getLocalNameFromTagName(tagName), 143 NameImpl.getPrefixFromTagName(tagName), 144 null); 145 } 146 147 public DocumentFragment createDocumentFragment() { 148 return document.createDocumentFragment(); 149 } 150 151 public org.w3c.dom.Text createTextNode(String data) { 152 return new SOAPTextImpl(this, data); 153 } 154 155 public Comment createComment(String data) { 156 return new SOAPCommentImpl(this, data); 157 } 158 159 public CDATASection createCDATASection(String data) throws DOMException { 160 return new CDATAImpl(this, data); 161 } 162 163 public ProcessingInstruction createProcessingInstruction( 164 String target, 165 String data) 166 throws DOMException { 167 log.severe("SAAJ0542.soap.proc.instructions.not.allowed.in.docs"); 168 throw new UnsupportedOperationException("Processing Instructions are not allowed in SOAP documents"); 169 } 170 171 public Attr createAttribute(String name) throws DOMException { 172 boolean isQualifiedName = (name.indexOf(":") > 0); 173 if (isQualifiedName) { 174 String nsUri = null; 175 String prefix = name.substring(0, name.indexOf(":")); 176 //cannot do anything to resolve the URI if prefix is not 177 //XMLNS. 178 if (XMLNS.equals(prefix)) { 179 nsUri = ElementImpl.XMLNS_URI; 180 return createAttributeNS(nsUri, name); 181 } 182 } 183 184 return document.createAttribute(name); 185 } 186 187 public EntityReference createEntityReference(String name) 188 throws DOMException { 189 log.severe("SAAJ0543.soap.entity.refs.not.allowed.in.docs"); 190 throw new UnsupportedOperationException("Entity References are not allowed in SOAP documents"); 191 } 192 193 public NodeList getElementsByTagName(String tagname) { 194 return document.getElementsByTagName(tagname); 195 } 196 197 public org.w3c.dom.Node importNode(Node importedNode, boolean deep) 198 throws DOMException { 199 final Node node = document.importNode(getDomNode(importedNode), deep); 200 return node instanceof Element ? 201 ElementFactory.createElement(this, (Element) node) 202 : node; 203 } 204 205 public Element createElementNS(String namespaceURI, String qualifiedName) 206 throws DOMException { 207 return ElementFactory.createElement( 208 this, 209 NameImpl.getLocalNameFromTagName(qualifiedName), 210 NameImpl.getPrefixFromTagName(qualifiedName), 211 namespaceURI); 212 } 213 214 public Attr createAttributeNS(String namespaceURI, String qualifiedName) 215 throws DOMException { 216 return document.createAttributeNS(namespaceURI, qualifiedName); 217 } 218 219 public NodeList getElementsByTagNameNS( 220 String namespaceURI, 221 String localName) { 222 return document.getElementsByTagNameNS(namespaceURI, localName); 223 } 224 225 public Element getElementById(String elementId) { 226 return document.getElementById(elementId); 227 } 228 229 @Override 230 public String getInputEncoding() { 231 return document.getInputEncoding(); 232 } 233 234 @Override 235 public String getXmlEncoding() { 236 return document.getXmlEncoding(); 237 } 238 239 @Override 240 public boolean getXmlStandalone() { 241 return document.getXmlStandalone(); 242 } 243 244 @Override | 88 try { 89 final DocumentBuilder documentBuilder = docFactory.newDocumentBuilder(); 90 return documentBuilder.newDocument(); 91 } catch (ParserConfigurationException e) { 92 throw new RuntimeException("Error creating xml document", e); 93 } 94 } 95 96 // public SOAPDocumentImpl(boolean grammarAccess) { 97 // super(grammarAccess); 98 // } 99 // 100 // public SOAPDocumentImpl(DocumentType doctype) { 101 // super(doctype); 102 // } 103 // 104 // public SOAPDocumentImpl(DocumentType doctype, boolean grammarAccess) { 105 // super(doctype, grammarAccess); 106 // } 107 108 @Override 109 public SOAPPartImpl getSOAPPart() { 110 if (enclosingSOAPPart == null) { 111 log.severe("SAAJ0541.soap.fragment.not.bound.to.part"); 112 throw new RuntimeException("Could not complete operation. Fragment not bound to SOAP part."); 113 } 114 return enclosingSOAPPart; 115 } 116 117 @Override 118 public SOAPDocumentImpl getDocument() { 119 return this; 120 } 121 122 @Override 123 public DocumentType getDoctype() { 124 // SOAP means no DTD, No DTD means no doctype (SOAP 1.2 only?) 125 return null; 126 } 127 128 @Override 129 public DOMImplementation getImplementation() { 130 return document.getImplementation(); 131 } 132 133 @Override 134 public Element getDocumentElement() { 135 // This had better be an Envelope! 136 getSOAPPart().doGetDocumentElement(); 137 return doGetDocumentElement(); 138 } 139 140 protected Element doGetDocumentElement() { 141 return document.getDocumentElement(); 142 } 143 144 @Override 145 public Element createElement(String tagName) throws DOMException { 146 return ElementFactory.createElement( 147 this, 148 NameImpl.getLocalNameFromTagName(tagName), 149 NameImpl.getPrefixFromTagName(tagName), 150 null); 151 } 152 153 @Override 154 public DocumentFragment createDocumentFragment() { 155 return document.createDocumentFragment(); 156 } 157 158 @Override 159 public org.w3c.dom.Text createTextNode(String data) { 160 return new SOAPTextImpl(this, data); 161 } 162 163 @Override 164 public Comment createComment(String data) { 165 return new SOAPCommentImpl(this, data); 166 } 167 168 @Override 169 public CDATASection createCDATASection(String data) throws DOMException { 170 return new CDATAImpl(this, data); 171 } 172 173 @Override 174 public ProcessingInstruction createProcessingInstruction( 175 String target, 176 String data) 177 throws DOMException { 178 log.severe("SAAJ0542.soap.proc.instructions.not.allowed.in.docs"); 179 throw new UnsupportedOperationException("Processing Instructions are not allowed in SOAP documents"); 180 } 181 182 @Override 183 public Attr createAttribute(String name) throws DOMException { 184 boolean isQualifiedName = (name.indexOf(":") > 0); 185 if (isQualifiedName) { 186 String nsUri = null; 187 String prefix = name.substring(0, name.indexOf(":")); 188 //cannot do anything to resolve the URI if prefix is not 189 //XMLNS. 190 if (XMLNS.equals(prefix)) { 191 nsUri = ElementImpl.XMLNS_URI; 192 return createAttributeNS(nsUri, name); 193 } 194 } 195 196 return document.createAttribute(name); 197 } 198 199 @Override 200 public EntityReference createEntityReference(String name) 201 throws DOMException { 202 log.severe("SAAJ0543.soap.entity.refs.not.allowed.in.docs"); 203 throw new UnsupportedOperationException("Entity References are not allowed in SOAP documents"); 204 } 205 206 @Override 207 public NodeList getElementsByTagName(String tagname) { 208 return document.getElementsByTagName(tagname); 209 } 210 211 @Override 212 public org.w3c.dom.Node importNode(Node importedNode, boolean deep) 213 throws DOMException { 214 final Node node = document.importNode(getDomNode(importedNode), deep); 215 return node instanceof Element ? 216 ElementFactory.createElement(this, (Element) node) 217 : node; 218 } 219 220 @Override 221 public Element createElementNS(String namespaceURI, String qualifiedName) 222 throws DOMException { 223 return ElementFactory.createElement( 224 this, 225 NameImpl.getLocalNameFromTagName(qualifiedName), 226 NameImpl.getPrefixFromTagName(qualifiedName), 227 namespaceURI); 228 } 229 230 @Override 231 public Attr createAttributeNS(String namespaceURI, String qualifiedName) 232 throws DOMException { 233 return document.createAttributeNS(namespaceURI, qualifiedName); 234 } 235 236 @Override 237 public NodeList getElementsByTagNameNS( 238 String namespaceURI, 239 String localName) { 240 return document.getElementsByTagNameNS(namespaceURI, localName); 241 } 242 243 @Override 244 public Element getElementById(String elementId) { 245 return document.getElementById(elementId); 246 } 247 248 @Override 249 public String getInputEncoding() { 250 return document.getInputEncoding(); 251 } 252 253 @Override 254 public String getXmlEncoding() { 255 return document.getXmlEncoding(); 256 } 257 258 @Override 259 public boolean getXmlStandalone() { 260 return document.getXmlStandalone(); 261 } 262 263 @Override |