| 1 |
/* |
| 2 |
* Copyright 2001-2004 The Apache Software Foundation. |
| 3 |
* |
| 4 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 |
* you may not use this file except in compliance with the License. |
| 6 |
* You may obtain a copy of the License at |
| 7 |
* |
| 8 |
* http://www.apache.org/licenses/LICENSE-2.0 |
| 9 |
* |
| 10 |
* Unless required by applicable law or agreed to in writing, software |
| 11 |
* distributed under the License is distributed on an "AS IS" BASIS, |
| 12 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 |
* See the License for the specific language governing permissions and |
| 14 |
* limitations under the License. |
| 15 |
*/ |
| 16 |
|
| 17 |
package org.apache.axis.message; |
| 18 |
|
| 19 |
import javax.xml.namespace.QName; |
| 20 |
import org.apache.axis.AxisFault; |
| 21 |
import org.apache.axis.Constants; |
| 22 |
import org.apache.axis.SOAPPart; |
| 23 |
import org.apache.axis.utils.Mapping; |
| 24 |
import org.apache.axis.utils.XMLUtils; |
| 25 |
import org.w3c.dom.Attr; |
| 26 |
import org.w3c.dom.CDATASection; |
| 27 |
import org.w3c.dom.Comment; |
| •28 |
import org.w3c.dom.DOMConfiguration; |
| 29 |
import org.w3c.dom.DOMException; |
| 30 |
import org.w3c.dom.DOMImplementation; |
| 31 |
import org.w3c.dom.Document; |
| 32 |
import org.w3c.dom.DocumentFragment; |
| 33 |
import org.w3c.dom.DocumentType; |
| 34 |
import org.w3c.dom.Element; |
| 35 |
import org.w3c.dom.EntityReference; |
| 36 |
import org.w3c.dom.NamedNodeMap; |
| 37 |
import org.w3c.dom.Node; |
| 38 |
import org.w3c.dom.NodeList; |
| 39 |
import org.w3c.dom.ProcessingInstruction; |
| •40 |
import org.w3c.dom.UserDataHandler; |
| 41 |
|
| 42 |
import javax.xml.parsers.ParserConfigurationException; |
| 43 |
import javax.xml.soap.SOAPException; |
| 44 |
|
| 45 |
/** |
| 46 |
* SOAPDcoumentImpl implements the Document API for SOAPPART. At the moment, it |
| 47 |
* again delgate the XERCES DOM Implementation Here is my argument on it: I |
| 48 |
* guess that there is 3 way to implement this. - fully implement the DOM API |
| 49 |
* here myself. => This is too much and duplicated work. - extends XERCES |
| 50 |
* Implementation => this makes we are fixed to one Implementation - choose |
| 51 |
* delgate depends on the user's parser preference => This is the practically |
| 52 |
* best solution I have now |
| 53 |
* |
| 54 |
* @author Heejune Ahn ([email protected]) |
| 55 |
* |
| 56 |
*/ |
| 57 |
|
| 58 |
public class SOAPDocumentImpl |
| 59 |
implements org.w3c.dom.Document, java.io.Serializable { |
| 60 |
|
| 61 |
// Depending on the user's parser preference |
| 62 |
protected Document delegate = null; |
| 63 |
protected SOAPPart soapPart = null; |
| 64 |
|
| 65 |
/** |
| 66 |
* Construct the Document |
| 67 |
* |
| 68 |
* @param sp the soap part |
| 69 |
*/ |
| 70 |
public SOAPDocumentImpl(SOAPPart sp) { |
| 71 |
try { |
| 72 |
delegate = XMLUtils.newDocument(); |
| 73 |
} catch (ParserConfigurationException e) { |
| 74 |
// Do nothing |
| 75 |
} |
| 76 |
soapPart = sp; |
| 77 |
} |
| 78 |
|
| 79 |
/** |
| 80 |
* @todo : link with SOAP |
| 81 |
* |
| 82 |
* @return |
| 83 |
*/ |
| 84 |
public DocumentType getDoctype() { |
| 85 |
return delegate.getDoctype(); |
| 86 |
} |
| 87 |
|
| 88 |
public DOMImplementation getImplementation() { |
| 89 |
return delegate.getImplementation(); |
| 90 |
} |
| 91 |
|
| 92 |
/** |
| 93 |
* should not be called, the method will be handled in SOAPPart |
| 94 |
* |
| 95 |
* @return |
| 96 |
*/ |
| 97 |
public Element getDocumentElement() { |
| 98 |
return soapPart.getDocumentElement(); |
| 99 |
} |
| 100 |
|
| 101 |
/** |
| 102 |
* based on the tagName, we will make different kind SOAP Elements Instance |
| 103 |
* Is really we can determine the Type by the Tagname??? |
| 104 |
* |
| 105 |
* @todo : verify this method |
| 106 |
* |
| 107 |
* @param tagName |
| 108 |
* @return @throws |
| 109 |
* DOMException |
| 110 |
*/ |
| 111 |
|
| 112 |
public org.w3c.dom.Element createElement(String tagName) |
| 113 |
throws DOMException { |
| 114 |
int index = tagName.indexOf(":"); |
| 115 |
String prefix, localname; |
| 116 |
if (index < 0) { |
| 117 |
prefix = ""; |
| 118 |
localname = tagName; |
| 119 |
} else { |
| 120 |
prefix = tagName.substring(0, index); |
| 121 |
localname = tagName.substring(index + 1); |
| 122 |
} |
| 123 |
|
| 124 |
try { |
| 125 |
SOAPEnvelope soapenv = |
| 126 |
(org.apache.axis.message.SOAPEnvelope) soapPart.getEnvelope(); |
| 127 |
if (soapenv != null) { |
| 128 |
if (tagName.equalsIgnoreCase(Constants.ELEM_ENVELOPE)) |
| 129 |
new SOAPEnvelope(); |
| 130 |
if (tagName.equalsIgnoreCase(Constants.ELEM_HEADER)) |
| 131 |
return new SOAPHeader(soapenv, soapenv.getSOAPConstants()); |
| 132 |
if (tagName.equalsIgnoreCase(Constants.ELEM_BODY)) |
| 133 |
return new SOAPBody(soapenv, soapenv.getSOAPConstants()); |
| 134 |
if (tagName.equalsIgnoreCase(Constants.ELEM_FAULT)) |
| 135 |
return new SOAPEnvelope(); |
| 136 |
if (tagName.equalsIgnoreCase(Constants.ELEM_FAULT_DETAIL)) |
| 137 |
return new SOAPFault(new AxisFault(tagName)); |
| 138 |
else { |
| 139 |
return new MessageElement("", prefix, localname); |
| 140 |
} |
| 141 |
} else { |
| 142 |
return new MessageElement("", prefix, localname); |
| 143 |
} |
| 144 |
|
| 145 |
} catch (SOAPException se) { |
| 146 |
throw new DOMException(DOMException.INVALID_STATE_ERR, ""); |
| 147 |
} |
| 148 |
} |
| 149 |
|
| 150 |
/** |
| 151 |
* |
| 152 |
* Creates an empty <code>DocumentFragment</code> object. @todo not |
| 153 |
* implemented yet |
| 154 |
* |
| 155 |
* @return A new <code>DocumentFragment</code>. |
| 156 |
*/ |
| 157 |
public DocumentFragment createDocumentFragment() { |
| 158 |
return delegate.createDocumentFragment(); |
| 159 |
} |
| 160 |
/** |
| 161 |
* Creates a <code>Text</code> node given the specified string. |
| 162 |
* |
| 163 |
* @param data |
| 164 |
* The data for the node. |
| 165 |
* @return The new <code>Text</code> object. |
| 166 |
*/ |
| 167 |
public org.w3c.dom.Text createTextNode(String data) { |
| 168 |
org.apache.axis.message.Text me = |
| 169 |
new org.apache.axis.message.Text(delegate.createTextNode(data)); |
| 170 |
me.setOwnerDocument(soapPart); |
| 171 |
return me; |
| 172 |
|
| 173 |
} |
| 174 |
|
| 175 |
/** |
| 176 |
* Creates a <code>Comment</code> node given the specified string. |
| 177 |
* |
| 178 |
* @param data |
| 179 |
* The data for the node. |
| 180 |
* @return The new <code>Comment</code> object. |
| 181 |
*/ |
| 182 |
public Comment createComment(String data) { |
| 183 |
return new org.apache.axis.message.CommentImpl(data); |
| 184 |
} |
| 185 |
|
| 186 |
/** |
| 187 |
* Creates a <code>CDATASection</code> node whose value is the specified |
| 188 |
* string. |
| 189 |
* |
| 190 |
* @param data |
| 191 |
* The data for the <code>CDATASection</code> contents. |
| 192 |
* @return The new <code>CDATASection</code> object. |
| 193 |
* @exception DOMException |
| 194 |
* NOT_SUPPORTED_ERR: Raised if this document is an HTML |
| 195 |
* document. |
| 196 |
*/ |
| 197 |
public CDATASection createCDATASection(String data) throws DOMException { |
| 198 |
return new CDATAImpl(data); |
| 199 |
} |
| 200 |
|
| 201 |
/** |
| 202 |
* Creates a <code>ProcessingInstruction</code> node given the specified |
| 203 |
* name and data strings. |
| 204 |
* |
| 205 |
* @param target |
| 206 |
* The target part of the processing instruction. |
| 207 |
* @param data |
| 208 |
* The data for the node. |
| 209 |
* @return The new <code>ProcessingInstruction</code> object. |
| 210 |
* @exception DOMException |
| 211 |
* INVALID_CHARACTER_ERR: Raised if the specified target |
| 212 |
* contains an illegal character. <br>NOT_SUPPORTED_ERR: |
| 213 |
* Raised if this document is an HTML document. |
| 214 |
*/ |
| 215 |
public ProcessingInstruction createProcessingInstruction( |
| 216 |
String target, |
| 217 |
String data) |
| 218 |
throws DOMException { |
| 219 |
throw new java.lang.UnsupportedOperationException( |
| 220 |
"createProcessingInstruction"); |
| 221 |
} |
| 222 |
|
| 223 |
/** |
| 224 |
* @todo: How Axis will maintain the Attribute representation ? |
| 225 |
*/ |
| 226 |
public Attr createAttribute(String name) throws DOMException { |
| 227 |
return delegate.createAttribute(name); |
| 228 |
} |
| 229 |
|
| 230 |
/** |
| 231 |
* @param name |
| 232 |
* @return @throws |
| 233 |
* DOMException |
| 234 |
*/ |
| 235 |
public EntityReference createEntityReference(String name) |
| 236 |
throws DOMException { |
| 237 |
throw new java.lang.UnsupportedOperationException( |
| 238 |
"createEntityReference"); |
| 239 |
} |
| 240 |
|
| 241 |
// implemented by yoonforh 2004-07-30 02:48:50 |
| 242 |
public Node importNode(Node importedNode, boolean deep) throws DOMException { |
| 243 |
Node targetNode = null; |
| 244 |
|
| 245 |
int type = importedNode.getNodeType(); |
| 246 |
switch (type) { |
| 247 |
case ELEMENT_NODE : |
| 248 |
Element el = (Element) importedNode; |
| 249 |
if (deep) { |
| 250 |
targetNode = new SOAPBodyElement(el); |
| 251 |
break; |
| 252 |
} |
| 253 |
|
| 254 |
SOAPBodyElement target = new SOAPBodyElement(); |
| 255 |
org.w3c.dom.NamedNodeMap attrs = el.getAttributes(); |
| 256 |
for (int i = 0; i < attrs.getLength(); i++) { |
| 257 |
org.w3c.dom.Node att = attrs.item(i); |
| 258 |
if (att.getNamespaceURI() != null && |
| 259 |
att.getPrefix() != null && |
| 260 |
att.getNamespaceURI().equals(Constants.NS_URI_XMLNS) && |
| 261 |
att.getPrefix().equals("xmlns")) { |
| 262 |
Mapping map = new Mapping(att.getNodeValue(), att.getLocalName()); |
| 263 |
target.addMapping(map); |
| 264 |
} |
| 265 |
if (att.getLocalName() != null) { |
| 266 |
target.addAttribute(att.getPrefix(), |
| 267 |
att.getNamespaceURI(), |
| 268 |
att.getLocalName(), |
| 269 |
att.getNodeValue()); |
| 270 |
} else if (att.getNodeName() != null) { |
| 271 |
target.addAttribute(att.getPrefix(), |
| 272 |
att.getNamespaceURI(), |
| 273 |
att.getNodeName(), |
| 274 |
att.getNodeValue()); |
| 275 |
} |
| 276 |
} |
| 277 |
|
| 278 |
if (el.getLocalName() == null) { |
| 279 |
target.setName(el.getNodeName()); |
| 280 |
} else { |
| 281 |
target.setQName(new QName(el.getNamespaceURI(), el.getLocalName())); |
| 282 |
} |
| 283 |
targetNode = target; |
| 284 |
break; |
| 285 |
|
| 286 |
case ATTRIBUTE_NODE : |
| 287 |
if (importedNode.getLocalName() == null) { |
| 288 |
targetNode = createAttribute(importedNode.getNodeName()); |
| 289 |
} else { |
| 290 |
targetNode = createAttributeNS(importedNode.getNamespaceURI(), |
| 291 |
importedNode.getLocalName()); |
| 292 |
} |
| 293 |
break; |
| 294 |
|
| 295 |
case TEXT_NODE : |
| 296 |
targetNode = createTextNode(importedNode.getNodeValue()); |
| 297 |
break; |
| 298 |
|
| 299 |
case CDATA_SECTION_NODE : |
| 300 |
targetNode = createCDATASection(importedNode.getNodeValue()); |
| 301 |
break; |
| 302 |
|
| 303 |
case COMMENT_NODE : |
| 304 |
targetNode = createComment(importedNode.getNodeValue()); |
| 305 |
break; |
| 306 |
|
| 307 |
case DOCUMENT_FRAGMENT_NODE : |
| 308 |
targetNode = createDocumentFragment(); |
| 309 |
if (deep) { |
| 310 |
org.w3c.dom.NodeList children = importedNode.getChildNodes(); |
| 311 |
for (int i = 0; i < children.getLength(); i++){ |
| 312 |
targetNode.appendChild(importNode(children.item(i), true)); |
| 313 |
} |
| 314 |
} |
| 315 |
break; |
| 316 |
|
| 317 |
case ENTITY_REFERENCE_NODE : |
| 318 |
targetNode = createEntityReference(importedNode.getNodeName()); |
| 319 |
break; |
| 320 |
|
| 321 |
case PROCESSING_INSTRUCTION_NODE : |
| 322 |
ProcessingInstruction pi = (ProcessingInstruction) importedNode; |
| 323 |
targetNode = createProcessingInstruction(pi.getTarget(), pi.getData()); |
| 324 |
break; |
| 325 |
|
| 326 |
case ENTITY_NODE : |
| 327 |
// TODO : ... |
| 328 |
throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Entity nodes are not supported."); |
| 329 |
|
| 330 |
case NOTATION_NODE : |
| 331 |
// TODO : any idea? |
| 332 |
throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Notation nodes are not supported."); |
| 333 |
|
| 334 |
case DOCUMENT_TYPE_NODE : |
| 335 |
throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "DocumentType nodes cannot be imported."); |
| 336 |
|
| 337 |
case DOCUMENT_NODE : |
| 338 |
throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Document nodes cannot be imported."); |
| 339 |
|
| 340 |
default : |
| 341 |
throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Node type (" + type + ") cannot be imported."); |
| 342 |
} |
| 343 |
|
| 344 |
return targetNode; |
| 345 |
} |
| 346 |
|
| 347 |
/** |
| 348 |
* Return SOAPElements (what if they want SOAPEnvelope or Header/Body?) |
| 349 |
* |
| 350 |
* @param namespaceURI |
| 351 |
* @param qualifiedName |
| 352 |
* @return @throws |
| 353 |
* DOMException |
| 354 |
*/ |
| 355 |
public Element createElementNS(String namespaceURI, String qualifiedName) |
| 356 |
throws DOMException { |
| 357 |
org.apache.axis.soap.SOAPConstants soapConstants = null; |
| 358 |
if (Constants.URI_SOAP11_ENV.equals(namespaceURI)) { |
| 359 |
soapConstants = org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS; |
| 360 |
} else if (Constants.URI_SOAP12_ENV.equals(namespaceURI)) { |
| 361 |
soapConstants = org.apache.axis.soap.SOAPConstants.SOAP12_CONSTANTS; |
| 362 |
} |
| 363 |
|
| 364 |
// For special SOAP Element |
| 365 |
MessageElement me = null; |
| 366 |
if (soapConstants != null) { |
| 367 |
if (qualifiedName.equals(Constants.ELEM_ENVELOPE)) { |
| 368 |
// TODO: confirm SOAP 1.1! |
| 369 |
me = new SOAPEnvelope(soapConstants); |
| 370 |
} else if (qualifiedName.equals(Constants.ELEM_HEADER)) { |
| 371 |
me = new SOAPHeader(null, soapConstants); |
| 372 |
// Dummy SOAPEnv required? |
| 373 |
} else if (qualifiedName.equals(Constants.ELEM_BODY)) { |
| 374 |
me = new SOAPBody(null, soapConstants); |
| 375 |
} else if (qualifiedName.equals(Constants.ELEM_FAULT)) { |
| 376 |
me = null; |
| 377 |
} else if (qualifiedName.equals(Constants.ELEM_FAULT_DETAIL)) { |
| 378 |
// TODO: |
| 379 |
me = null; |
| 380 |
} else { |
| 381 |
throw new DOMException( |
| 382 |
DOMException.INVALID_STATE_ERR, |
| 383 |
"No such Localname for SOAP URI"); |
| 384 |
} |
| 385 |
// TODO: |
| 386 |
return null; |
| 387 |
// general Elements |
| 388 |
} else { |
| 389 |
me = new MessageElement(namespaceURI, qualifiedName); |
| 390 |
} |
| 391 |
|
| 392 |
if (me != null) |
| 393 |
me.setOwnerDocument(soapPart); |
| 394 |
|
| 395 |
return me; |
| 396 |
|
| 397 |
} |
| 398 |
|
| 399 |
/** |
| 400 |
* Attribute is not particularly dealt with in SAAJ. |
| 401 |
* |
| 402 |
*/ |
| 403 |
public Attr createAttributeNS(String namespaceURI, String qualifiedName) |
| 404 |
throws DOMException { |
| 405 |
return delegate.createAttributeNS(namespaceURI, qualifiedName); |
| 406 |
} |
| 407 |
|
| 408 |
/** |
| 409 |
* search the SOAPPart in order of SOAPHeader and SOAPBody for the |
| 410 |
* requested Element name |
| 411 |
* |
| 412 |
*/ |
| 413 |
public NodeList getElementsByTagNameNS( |
| 414 |
String namespaceURI, |
| 415 |
String localName) { |
| 416 |
try { |
| 417 |
NodeListImpl list = new NodeListImpl(); |
| 418 |
if (soapPart != null) { |
| 419 |
SOAPEnvelope soapEnv = |
| 420 |
(org.apache.axis.message.SOAPEnvelope) soapPart |
| 421 |
.getEnvelope(); |
| 422 |
SOAPHeader header = |
| 423 |
(org.apache.axis.message.SOAPHeader) soapEnv.getHeader(); |
| 424 |
if (header != null) { |
| 425 |
list.addNodeList(header.getElementsByTagNameNS( |
| 426 |
namespaceURI, |
| 427 |
localName)); |
| 428 |
} |
| 429 |
SOAPBody body = |
| 430 |
(org.apache.axis.message.SOAPBody) soapEnv.getBody(); |
| 431 |
if (body != null) { |
| 432 |
list.addNodeList(body.getElementsByTagNameNS( |
| 433 |
namespaceURI, |
| 434 |
localName)); |
| 435 |
} |
| 436 |
} |
| 437 |
return list; |
| 438 |
} catch (SOAPException se) { |
| 439 |
throw new DOMException(DOMException.INVALID_STATE_ERR, ""); |
| 440 |
} |
| 441 |
} |
| 442 |
|
| 443 |
/** |
| 444 |
* search the SOAPPart in order of SOAPHeader and SOAPBody for the |
| 445 |
* requested Element name |
| 446 |
* |
| 447 |
*/ |
| 448 |
public NodeList getElementsByTagName(String localName) { |
| 449 |
|
| 450 |
try { |
| 451 |
NodeListImpl list = new NodeListImpl(); |
| 452 |
if (soapPart != null) { |
| 453 |
SOAPEnvelope soapEnv = |
| 454 |
(org.apache.axis.message.SOAPEnvelope) soapPart |
| 455 |
.getEnvelope(); |
| 456 |
SOAPHeader header = |
| 457 |
(org.apache.axis.message.SOAPHeader) soapEnv.getHeader(); |
| 458 |
if (header != null) { |
| 459 |
list.addNodeList(header.getElementsByTagName(localName)); |
| 460 |
} |
| 461 |
SOAPBody body = |
| 462 |
(org.apache.axis.message.SOAPBody) soapEnv.getBody(); |
| 463 |
if (body != null) { |
| 464 |
list.addNodeList(body.getElementsByTagName(localName)); |
| 465 |
} |
| 466 |
} |
| 467 |
return list; |
| 468 |
} catch (SOAPException se) { |
| 469 |
throw new DOMException(DOMException.INVALID_STATE_ERR, ""); |
| 470 |
} |
| 471 |
} |
| 472 |
/** |
| 473 |
* Returns the <code>Element</code> whose <code>ID</code> is given by |
| 474 |
* <code>elementId</code>. If no such element exists, returns <code>null</code>. |
| 475 |
* Behavior is not defined if more than one element has this <code>ID</code>. |
| 476 |
* The DOM implementation must have information that says which attributes |
| 477 |
* are of type ID. Attributes with the name "ID" are not of type ID unless |
| 478 |
* so defined. Implementations that do not know whether attributes are of |
| 479 |
* type ID or not are expected to return <code>null</code>. |
| 480 |
* |
| 481 |
* @param elementId |
| 482 |
* The unique <code>id</code> value for an element. |
| 483 |
* @return The matching element. |
| 484 |
* @since DOM Level 2 |
| 485 |
*/ |
| 486 |
public Element getElementById(String elementId) { |
| 487 |
return delegate.getElementById(elementId); |
| 488 |
} |
| 489 |
|
| 490 |
/** |
| 491 |
* Node Implementation |
| 492 |
* |
| 493 |
*/ |
| 494 |
|
| 495 |
public String getNodeName() { |
| 496 |
return null; |
| 497 |
} |
| 498 |
|
| 499 |
public String getNodeValue() throws DOMException { |
| 500 |
throw new DOMException( |
| 501 |
DOMException.NO_DATA_ALLOWED_ERR, |
| 502 |
"Cannot use TextNode.get in " + this); |
| 503 |
} |
| 504 |
|
| 505 |
public void setNodeValue(String nodeValue) throws DOMException { |
| 506 |
throw new DOMException( |
| 507 |
DOMException.NO_DATA_ALLOWED_ERR, |
| 508 |
"Cannot use TextNode.set in " + this); |
| 509 |
} |
| 510 |
|
| 511 |
/** |
| 512 |
* override it in sub-classes |
| 513 |
* |
| 514 |
* @return |
| 515 |
*/ |
| 516 |
public short getNodeType() { |
| 517 |
return Node.DOCUMENT_NODE; |
| 518 |
} |
| 519 |
|
| 520 |
public Node getParentNode() { |
| 521 |
return null; |
| 522 |
} |
| 523 |
|
| 524 |
public NodeList getChildNodes() { |
| 525 |
try { |
| 526 |
if (soapPart != null) { |
| 527 |
NodeListImpl children = new NodeListImpl(); |
| 528 |
children.addNode(soapPart.getEnvelope()); |
| 529 |
return children; |
| 530 |
} else { |
| 531 |
return NodeListImpl.EMPTY_NODELIST; |
| 532 |
} |
| 533 |
} catch (SOAPException se) { |
| 534 |
throw new DOMException(DOMException.INVALID_STATE_ERR, ""); |
| 535 |
} |
| 536 |
|
| 537 |
} |
| 538 |
|
| 539 |
/** |
| 540 |
* Do we have to count the Attributes as node ???? |
| 541 |
* |
| 542 |
* @return |
| 543 |
*/ |
| 544 |
public Node getFirstChild() { |
| 545 |
try { |
| 546 |
if (soapPart != null) |
| 547 |
return (org.apache.axis.message.SOAPEnvelope) soapPart |
| 548 |
.getEnvelope(); |
| 549 |
else |
| 550 |
return null; |
| 551 |
} catch (SOAPException se) { |
| 552 |
throw new DOMException(DOMException.INVALID_STATE_ERR, ""); |
| 553 |
} |
| 554 |
|
| 555 |
} |
| 556 |
|
| 557 |
/** |
| 558 |
* @return |
| 559 |
*/ |
| 560 |
public Node getLastChild() { |
| 561 |
try { |
| 562 |
if (soapPart != null) |
| 563 |
return (org.apache.axis.message.SOAPEnvelope) soapPart |
| 564 |
.getEnvelope(); |
| 565 |
else |
| 566 |
return null; |
| 567 |
} catch (SOAPException se) { |
| 568 |
throw new DOMException(DOMException.INVALID_STATE_ERR, ""); |
| 569 |
} |
| 570 |
|
| 571 |
} |
| 572 |
|
| 573 |
public Node getPreviousSibling() { |
| 574 |
return null; |
| 575 |
} |
| 576 |
public Node getNextSibling() { |
| 577 |
|
| 578 |
return null; |
| 579 |
} |
| 580 |
|
| 581 |
public NamedNodeMap getAttributes() { |
| 582 |
return null; |
| 583 |
} |
| 584 |
|
| 585 |
/** |
| 586 |
* |
| 587 |
* we have to have a link to them... |
| 588 |
*/ |
| 589 |
public Document getOwnerDocument() { |
| 590 |
return null; |
| 591 |
} |
| 592 |
|
| 593 |
/** |
| 594 |
*/ |
| 595 |
public Node insertBefore(Node newChild, Node refChild) |
| 596 |
throws DOMException { |
| 597 |
throw new DOMException(DOMException.NOT_SUPPORTED_ERR, ""); |
| 598 |
} |
| 599 |
|
| 600 |
public Node replaceChild(Node newChild, Node oldChild) |
| 601 |
throws DOMException { |
| 602 |
throw new DOMException(DOMException.NOT_SUPPORTED_ERR, ""); |
| 603 |
} |
| 604 |
|
| 605 |
public Node removeChild(Node oldChild) throws DOMException { |
| 606 |
try { |
| 607 |
Node envNode; |
| 608 |
if (soapPart != null) { |
| 609 |
envNode = soapPart.getEnvelope(); |
| 610 |
if (envNode.equals(oldChild)) { |
| 611 |
return envNode; |
| 612 |
} |
| 613 |
} |
| 614 |
throw new DOMException(DOMException.NOT_SUPPORTED_ERR, ""); |
| 615 |
} catch (SOAPException se) { |
| 616 |
throw new DOMException(DOMException.INVALID_STATE_ERR, ""); |
| 617 |
} |
| 618 |
} |
| 619 |
|
| 620 |
public Node appendChild(Node newChild) throws DOMException { |
| 621 |
throw new DOMException(DOMException.NOT_SUPPORTED_ERR, ""); |
| 622 |
} |
| 623 |
|
| 624 |
public boolean hasChildNodes() { |
| 625 |
try { |
| 626 |
if (soapPart != null) { |
| 627 |
if (soapPart.getEnvelope() != null) { |
| 628 |
return true; |
| 629 |
} |
| 630 |
} |
| 631 |
return false; |
| 632 |
} catch (SOAPException se) { |
| 633 |
throw new DOMException(DOMException.INVALID_STATE_ERR, ""); |
| 634 |
} |
| 635 |
|
| 636 |
} |
| 637 |
|
| 638 |
/** |
| 639 |
* @todo: Study it more.... to implement the deep mode correctly. |
| 640 |
* |
| 641 |
*/ |
| 642 |
public Node cloneNode(boolean deep) { |
| 643 |
throw new DOMException(DOMException.NOT_SUPPORTED_ERR, ""); |
| 644 |
} |
| 645 |
|
| 646 |
/** |
| 647 |
* @todo: is it OK to simply call the superclass? |
| 648 |
* |
| 649 |
*/ |
| 650 |
public void normalize() { |
| 651 |
throw new DOMException(DOMException.NOT_SUPPORTED_ERR, ""); |
| 652 |
} |
| 653 |
|
| 654 |
// TODO: fill appropriate features |
| 655 |
private String[] features = { "foo", "bar" }; |
| 656 |
private String version = "version 2.0"; |
| 657 |
|
| 658 |
public boolean isSupported(String feature, String version) { |
| 659 |
if (!version.equalsIgnoreCase(version)) |
| 660 |
return false; |
| 661 |
else |
| 662 |
return true; |
| 663 |
} |
| 664 |
|
| 665 |
public String getPrefix() { |
| 666 |
throw new DOMException(DOMException.NOT_SUPPORTED_ERR, ""); |
| 667 |
} |
| 668 |
public void setPrefix(String prefix) { |
| 669 |
throw new DOMException(DOMException.NOT_SUPPORTED_ERR, ""); |
| 670 |
} |
| 671 |
|
| 672 |
public String getNamespaceURI() { |
| 673 |
throw new DOMException(DOMException.NOT_SUPPORTED_ERR, ""); |
| 674 |
} |
| 675 |
public void setNamespaceURI(String nsURI) { |
| 676 |
throw new DOMException(DOMException.NOT_SUPPORTED_ERR, ""); |
| 677 |
} |
| 678 |
|
| 679 |
public String getLocalName() { |
| 680 |
throw new DOMException(DOMException.NOT_SUPPORTED_ERR, ""); |
| 681 |
} |
| 682 |
|
| 683 |
public boolean hasAttributes() { |
| 684 |
throw new DOMException(DOMException.NOT_SUPPORTED_ERR, ""); |
| 685 |
} |
| •686 |
|
| 687 |
/** |
| 688 |
* DOM Level 3 stubs |
| 689 |
*/ |
| 690 |
|
| 691 |
public String getBaseURI() { |
| 692 |
throw new DOMException(DOMException.NOT_SUPPORTED_ERR, ""); |
| 693 |
} |
| 694 |
|
| 695 |
public boolean getXmlStandalone() { |
| 696 |
throw new DOMException(DOMException.NOT_SUPPORTED_ERR, ""); |
| 697 |
} |
| 698 |
|
| 699 |
public boolean getStrictErrorChecking() { |
| 700 |
throw new DOMException(DOMException.NOT_SUPPORTED_ERR, ""); |
| 701 |
} |
| 702 |
|
| 703 |
public void setXmlStandalone(boolean xmlStandalone) { |
| 704 |
throw new DOMException(DOMException.NOT_SUPPORTED_ERR, ""); |
| 705 |
} |
| 706 |
|
| 707 |
public Node renameNode(Node n, String namespaceURI, String qualifiedName) { |
| 708 |
throw new DOMException(DOMException.NOT_SUPPORTED_ERR, ""); |
| 709 |
} |
| 710 |
|
| 711 |
public void setStrictErrorChecking(boolean strictErrorChecking) { |
| 712 |
throw new DOMException(DOMException.NOT_SUPPORTED_ERR, ""); |
| 713 |
} |
| 714 |
|
| 715 |
public Object setUserData( |
| 716 |
String key, Object data, UserDataHandler handler) { |
| 717 |
throw new DOMException(DOMException.NOT_SUPPORTED_ERR, ""); |
| 718 |
} |
| 719 |
|
| 720 |
public String getInputEncoding() { |
| 721 |
throw new DOMException(DOMException.NOT_SUPPORTED_ERR, ""); |
| 722 |
} |
| 723 |
|
| 724 |
public String getXmlEncoding() { |
| 725 |
throw new DOMException(DOMException.NOT_SUPPORTED_ERR, ""); |
| 726 |
} |
| 727 |
|
| 728 |
public void setTextContent(String textContent) { |
| 729 |
throw new DOMException(DOMException.NOT_SUPPORTED_ERR, ""); |
| 730 |
} |
| 731 |
|
| 732 |
public boolean isSameNode(Node other) { |
| 733 |
throw new DOMException(DOMException.NOT_SUPPORTED_ERR, ""); |
| 734 |
} |
| 735 |
|
| 736 |
public String getDocumentURI() { |
| 737 |
throw new DOMException(DOMException.NOT_SUPPORTED_ERR, ""); |
| 738 |
} |
| 739 |
|
| 740 |
public void setDocumentURI(String documentURI) { |
| 741 |
throw new DOMException(DOMException.NOT_SUPPORTED_ERR, ""); |
| 742 |
} |
| 743 |
|
| 744 |
public Object getFeature(String feature, String version) { |
| 745 |
throw new DOMException(DOMException.NOT_SUPPORTED_ERR, ""); |
| 746 |
} |
| 747 |
|
| 748 |
public Node adoptNode(Node source) { |
| 749 |
throw new DOMException(DOMException.NOT_SUPPORTED_ERR, ""); |
| 750 |
} |
| 751 |
|
| 752 |
public boolean isDefaultNamespace(String namespaceURI) { |
| 753 |
throw new DOMException(DOMException.NOT_SUPPORTED_ERR, ""); |
| 754 |
} |
| 755 |
|
| 756 |
public boolean isEqualNode(Node arg) { |
| 757 |
throw new DOMException(DOMException.NOT_SUPPORTED_ERR, ""); |
| 758 |
} |
| 759 |
|
| 760 |
public void setXmlVersion(String xmlVersion) { |
| 761 |
throw new DOMException(DOMException.NOT_SUPPORTED_ERR, ""); |
| 762 |
} |
| 763 |
|
| 764 |
public String getXmlVersion() { |
| 765 |
throw new DOMException(DOMException.NOT_SUPPORTED_ERR, ""); |
| 766 |
} |
| 767 |
|
| 768 |
public String lookupPrefix(String namespaceURI) { |
| 769 |
throw new DOMException(DOMException.NOT_SUPPORTED_ERR, ""); |
| 770 |
} |
| 771 |
|
| 772 |
public Object getUserData(String key) { |
| 773 |
throw new DOMException(DOMException.NOT_SUPPORTED_ERR, ""); |
| 774 |
} |
| 775 |
|
| 776 |
public String getTextContent() { |
| 777 |
throw new DOMException(DOMException.NOT_SUPPORTED_ERR, ""); |
| 778 |
} |
| 779 |
|
| 780 |
public void normalizeDocument() { |
| 781 |
throw new DOMException(DOMException.NOT_SUPPORTED_ERR, ""); |
| 782 |
} |
| 783 |
|
| 784 |
public String lookupNamespaceURI(String prefix) { |
| 785 |
throw new DOMException(DOMException.NOT_SUPPORTED_ERR, ""); |
| 786 |
} |
| 787 |
|
| 788 |
public DOMConfiguration getDomConfig() { |
| 789 |
throw new DOMException(DOMException.NOT_SUPPORTED_ERR, ""); |
| 790 |
} |
| 791 |
|
| 792 |
public short compareDocumentPosition(Node other) { |
| 793 |
throw new DOMException(DOMException.NOT_SUPPORTED_ERR, ""); |
| 794 |
} |
| 795 |
} |