0001: /*
0002: * Licensed to the Apache Software Foundation (ASF) under one
0003: * or more contributor license agreements. See the NOTICE file
0004: * distributed with this work for additional information
0005: * regarding copyright ownership. The ASF licenses this file
0006: * to you under the Apache License, Version 2.0 (the
0007: * "License"); you may not use this file except in compliance
0008: * with the License. You may obtain a copy of the License at
0009: *
0010: * http://www.apache.org/licenses/LICENSE-2.0
0011: *
0012: * Unless required by applicable law or agreed to in writing,
0013: * software distributed under the License is distributed on an
0014: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
0015: * KIND, either express or implied. See the License for the
0016: * specific language governing permissions and limitations
0017: * under the License.
0018: */
0019: package org.apache.axis2.saaj;
0020:
0021: import java.io.ByteArrayInputStream;
0022: import java.io.ByteArrayOutputStream;
0023: import java.io.InputStream;
0024: import java.io.InputStreamReader;
0025: import java.util.Iterator;
0026:
0027: import javax.xml.soap.MimeHeader;
0028: import javax.xml.soap.MimeHeaders;
0029: import javax.xml.soap.SOAPElement;
0030: import javax.xml.soap.SOAPEnvelope;
0031: import javax.xml.soap.SOAPException;
0032: import javax.xml.soap.SOAPMessage;
0033: import javax.xml.soap.SOAPPart;
0034: import javax.xml.stream.XMLInputFactory;
0035: import javax.xml.stream.XMLStreamException;
0036: import javax.xml.stream.XMLStreamReader;
0037: import javax.xml.transform.Result;
0038: import javax.xml.transform.Source;
0039: import javax.xml.transform.Transformer;
0040: import javax.xml.transform.TransformerFactory;
0041: import javax.xml.transform.TransformerFactoryConfigurationError;
0042: import javax.xml.transform.dom.DOMSource;
0043: import javax.xml.transform.stream.StreamResult;
0044: import javax.xml.transform.stream.StreamSource;
0045:
0046: import org.apache.axiom.attachments.Attachments;
0047: import org.apache.axiom.om.impl.MTOMConstants;
0048: import org.apache.axiom.om.util.StAXUtils;
0049: import org.apache.axiom.soap.SOAP11Constants;
0050: import org.apache.axiom.soap.SOAP12Constants;
0051: import org.apache.axiom.soap.SOAPFactory;
0052: import org.apache.axiom.soap.impl.builder.MTOMStAXSOAPModelBuilder;
0053: import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder;
0054: import org.apache.axiom.soap.impl.dom.soap11.SOAP11Factory;
0055: import org.apache.axiom.soap.impl.dom.soap12.SOAP12Factory;
0056: import org.apache.axis2.builder.BuilderUtil;
0057: import org.apache.axis2.saaj.util.IDGenerator;
0058: import org.apache.axis2.transport.http.HTTPConstants;
0059: import org.apache.commons.logging.Log;
0060: import org.apache.commons.logging.LogFactory;
0061: import org.w3c.dom.Attr;
0062: import org.w3c.dom.CDATASection;
0063: import org.w3c.dom.Comment;
0064: import org.w3c.dom.DOMConfiguration;
0065: import org.w3c.dom.DOMException;
0066: import org.w3c.dom.DOMImplementation;
0067: import org.w3c.dom.Document;
0068: import org.w3c.dom.DocumentFragment;
0069: import org.w3c.dom.DocumentType;
0070: import org.w3c.dom.Element;
0071: import org.w3c.dom.EntityReference;
0072: import org.w3c.dom.NamedNodeMap;
0073: import org.w3c.dom.Node;
0074: import org.w3c.dom.NodeList;
0075: import org.w3c.dom.ProcessingInstruction;
0076: import org.w3c.dom.Text;
0077: import org.w3c.dom.UserDataHandler;
0078:
0079: public class SOAPPartImpl extends SOAPPart {
0080:
0081: private static final Log log = LogFactory
0082: .getLog(SOAPPartImpl.class);
0083:
0084: private Document document;
0085: private SOAPMessage soapMessage;
0086: private SOAPEnvelopeImpl envelope;
0087: private MimeHeadersEx mimeHeaders = new MimeHeadersEx();
0088:
0089: private Source source;
0090:
0091: public SOAPPartImpl(SOAPMessageImpl parentSoapMsg,
0092: SOAPEnvelopeImpl soapEnvelope) {
0093: //setMimeHeader(HTTPConstants.HEADER_CONTENT_ID, IDGenerator.generateID());
0094: //setMimeHeader(HTTPConstants.HEADER_CONTENT_TYPE, "text/xml");
0095: this .mimeHeaders = (MimeHeadersEx) parentSoapMsg
0096: .getMimeHeaders();
0097: soapMessage = parentSoapMsg;
0098: envelope = soapEnvelope;
0099: document = soapEnvelope.getOwnerDocument();
0100: }
0101:
0102: public SOAPPartImpl(SOAPMessageImpl parentSoapMsg,
0103: InputStream inputStream,
0104: javax.xml.soap.MimeHeaders mimeHeaders)
0105: throws SOAPException {
0106: String contentType = "";
0107: String fullContentTypeStr = "";
0108: if (mimeHeaders == null) {
0109: //TODO : read string from constants
0110: mimeHeaders = new MimeHeaders();
0111: mimeHeaders.addHeader("Content-ID", IDGenerator
0112: .generateID());
0113: mimeHeaders.addHeader("content-type",
0114: HTTPConstants.MEDIA_TYPE_APPLICATION_SOAP_XML);
0115: } else {
0116: String contentTypes[] = mimeHeaders
0117: .getHeader(HTTPConstants.CONTENT_TYPE);
0118: if (contentTypes != null && contentTypes.length > 0) {
0119: fullContentTypeStr = contentTypes[0];
0120: contentType = extractFirstPart(fullContentTypeStr);
0121: }
0122: }
0123:
0124: Iterator mimeHeaderIterator = mimeHeaders.getAllHeaders();
0125: while (mimeHeaderIterator.hasNext()) {
0126: MimeHeader mimeHeader = (MimeHeader) mimeHeaderIterator
0127: .next();
0128: String value = mimeHeader.getValue();
0129: setMimeHeader(mimeHeader.getName(), value);
0130: }
0131: soapMessage = parentSoapMsg;
0132:
0133: String knownEncoding = (String) soapMessage
0134: .getProperty(SOAPMessage.CHARACTER_SET_ENCODING);
0135: XMLStreamReader xmlReader = null;
0136:
0137: InputStream modifiedInputStream = null;
0138: StAXSOAPModelBuilder builder = null;
0139: InputStreamReader isReader = null;
0140:
0141: if (contentType.indexOf("multipart/related") == 0) {
0142: //This contains attachements
0143: try {
0144: Attachments attachments = new Attachments(inputStream,
0145: fullContentTypeStr, false, "", "");
0146: modifiedInputStream = attachments
0147: .getSOAPPartInputStream();
0148: isReader = new InputStreamReader(modifiedInputStream);
0149:
0150: String soapEnvelopeNamespaceURI = BuilderUtil
0151: .getEnvelopeNamespace(fullContentTypeStr);
0152:
0153: String charSetEncoding = BuilderUtil
0154: .getCharSetEncoding(attachments
0155: .getSOAPPartContentType());
0156:
0157: XMLStreamReader streamReader = StAXUtils
0158: .createXMLStreamReader(BuilderUtil.getReader(
0159: attachments.getSOAPPartInputStream(),
0160: charSetEncoding));
0161:
0162: SOAPFactory factory;
0163: if (SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI
0164: .equals(soapEnvelopeNamespaceURI)) {
0165: factory = new SOAP11Factory();
0166: } else {
0167: factory = new SOAP12Factory();
0168: }
0169: if (attachments.getAttachmentSpecType().equals(
0170: MTOMConstants.MTOM_TYPE)) {
0171: //Creates the MTOM specific MTOMStAXSOAPModelBuilder
0172: builder = new MTOMStAXSOAPModelBuilder(
0173: streamReader, factory, attachments,
0174: soapEnvelopeNamespaceURI);
0175: } else if (attachments.getAttachmentSpecType().equals(
0176: MTOMConstants.SWA_TYPE)) {
0177: builder = new StAXSOAPModelBuilder(streamReader,
0178: factory, soapEnvelopeNamespaceURI);
0179: } else if (attachments.getAttachmentSpecType().equals(
0180: MTOMConstants.SWA_TYPE_12)) {
0181: builder = new StAXSOAPModelBuilder(streamReader,
0182: factory, soapEnvelopeNamespaceURI);
0183: }
0184:
0185: } catch (Exception e) {
0186: throw new SOAPException(e);
0187: }
0188: } else {
0189: modifiedInputStream = inputStream;
0190: try {
0191: isReader = new InputStreamReader(modifiedInputStream);
0192: XMLStreamReader streamReader = null;
0193:
0194: if (knownEncoding != null) {
0195: streamReader = StAXUtils.createXMLStreamReader(
0196: modifiedInputStream, knownEncoding);
0197: } else {
0198: streamReader = StAXUtils
0199: .createXMLStreamReader(modifiedInputStream);
0200: }
0201:
0202: if (HTTPConstants.MEDIA_TYPE_TEXT_XML
0203: .equals(contentType)) {
0204: builder = new StAXSOAPModelBuilder(streamReader,
0205: new SOAP11Factory(),
0206: SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
0207:
0208: } else if (HTTPConstants.MEDIA_TYPE_APPLICATION_SOAP_XML
0209: .equals(contentType)) {
0210: builder = new StAXSOAPModelBuilder(streamReader,
0211: new SOAP12Factory(),
0212: SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
0213:
0214: } else if (HTTPConstants.MEDIA_TYPE_MULTIPART_RELATED
0215: .equals(contentType)) {
0216: builder = new StAXSOAPModelBuilder(streamReader,
0217: new SOAP11Factory(), null);
0218: } else {
0219: builder = new StAXSOAPModelBuilder(streamReader,
0220: new SOAP11Factory(), null);
0221: }
0222: } catch (XMLStreamException e) {
0223: throw new SOAPException(e);
0224: }
0225: }
0226: try {
0227: org.apache.axiom.soap.SOAPEnvelope soapEnvelope = builder
0228: .getSOAPEnvelope();
0229: envelope = new SOAPEnvelopeImpl(
0230: (org.apache.axiom.soap.impl.dom.SOAPEnvelopeImpl) soapEnvelope);
0231: envelope.element.build();
0232: this .document = envelope.getOwnerDocument();
0233: javax.xml.transform.Source xmlSource = new javax.xml.transform.stream.StreamSource(
0234: isReader);
0235: this .source = xmlSource;
0236: } catch (Exception e) {
0237: throw new SOAPException(e);
0238: }
0239: }
0240:
0241: private String extractFirstPart(String fullContentTypeStr) {
0242: String contentType;//tmpContentType can be like 'application/soap+xml; charset=UTF-8;'
0243: //Only the first part is important
0244: if (fullContentTypeStr.indexOf(";") > -1) {
0245: contentType = fullContentTypeStr.substring(0,
0246: fullContentTypeStr.indexOf(";"));
0247: } else {
0248: contentType = fullContentTypeStr;
0249: }
0250: return contentType;
0251: }
0252:
0253: public SOAPPartImpl(SOAPMessageImpl parentSoapMsg,
0254: InputStream inputStream) throws SOAPException {
0255: this (parentSoapMsg, inputStream, null);
0256: }
0257:
0258: /**
0259: * Obtain the SOAPMessage
0260: *
0261: * @return the related SOAPMessage
0262: */
0263: public SOAPMessage getSoapMessage() {
0264: return soapMessage;
0265: }
0266:
0267: /**
0268: * Gets the <CODE>SOAPEnvelope</CODE> object associated with this <CODE>SOAPPart</CODE> object.
0269: * Once the SOAP envelope is obtained, it can be used to get its contents.
0270: *
0271: * @return the <CODE>SOAPEnvelope</CODE> object for this <CODE> SOAPPart</CODE> object
0272: * @throws SOAPException if there is a SOAP error
0273: */
0274: public SOAPEnvelope getEnvelope() throws SOAPException {
0275: return envelope;
0276: }
0277:
0278: /**
0279: * Removes all MIME headers that match the given name.
0280: *
0281: * @param header a <CODE>String</CODE> giving the name of the MIME header(s) to be removed
0282: */
0283: public void removeMimeHeader(String header) {
0284: mimeHeaders.removeHeader(header);
0285: }
0286:
0287: /** Removes all the <CODE>MimeHeader</CODE> objects for this <CODE>SOAPEnvelope</CODE> object. */
0288: public void removeAllMimeHeaders() {
0289: mimeHeaders.removeAllHeaders();
0290: }
0291:
0292: /**
0293: * Gets all the values of the <CODE>MimeHeader</CODE> object in this <CODE>SOAPPart</CODE>
0294: * object that is identified by the given <CODE>String</CODE>.
0295: *
0296: * @param name the name of the header; example: "Content-Type"
0297: * @return a <CODE>String</CODE> array giving all the values for the specified header
0298: * @see #setMimeHeader(String, String) setMimeHeader(java.lang.String,
0299: * java.lang.String)
0300: */
0301: public String[] getMimeHeader(String name) {
0302: return mimeHeaders.getHeader(name);
0303: }
0304:
0305: /**
0306: * Changes the first header entry that matches the given header name so that its value is the
0307: * given value, adding a new header with the given name and value if no existing header is a
0308: * match. If there is a match, this method clears all existing values for the first header that
0309: * matches and sets the given value instead. If more than one header has the given name, this
0310: * method removes all of the matching headers after the first one.
0311: * <p/>
0312: * <P>Note that RFC822 headers can contain only US-ASCII characters.</P>
0313: *
0314: * @param name a <CODE>String</CODE> giving the header name for which to search
0315: * @param value a <CODE>String</CODE> giving the value to be set. This value will be substituted
0316: * for the current value(s) of the first header that is a match if there is one. If
0317: * there is no match, this value will be the value for a new
0318: * <CODE>MimeHeader</CODE> object.
0319: * @throws IllegalArgumentException
0320: * if there was a problem with the specified mime header name or value
0321: * @throws IllegalArgumentException
0322: * if there was a problem with the specified mime header name or value
0323: * @see #getMimeHeader(String) getMimeHeader(java.lang.String)
0324: */
0325: public void setMimeHeader(String name, String value) {
0326: mimeHeaders.setHeader(name, value);
0327: }
0328:
0329: /**
0330: * Creates a <CODE>MimeHeader</CODE> object with the specified name and value and adds it to
0331: * this <CODE>SOAPPart</CODE> object. If a <CODE>MimeHeader</CODE> with the specified name
0332: * already exists, this method adds the specified value to the already existing value(s).
0333: * <p/>
0334: * <P>Note that RFC822 headers can contain only US-ASCII characters.</P>
0335: *
0336: * @param header a <CODE>String</CODE> giving the header name
0337: * @param value a <CODE>String</CODE> giving the value to be set or added
0338: * @throws IllegalArgumentException if there was a problem with the specified mime header name
0339: * or value
0340: */
0341: public void addMimeHeader(String header, String value) {
0342: mimeHeaders.addHeader(header, value);
0343: }
0344:
0345: /**
0346: * Retrieves all the headers for this <CODE>SOAPPart</CODE> object as an iterator over the
0347: * <CODE>MimeHeader</CODE> objects.
0348: *
0349: * @return an <CODE>Iterator</CODE> object with all of the Mime headers for this
0350: * <CODE>SOAPPart</CODE> object
0351: */
0352: public Iterator getAllMimeHeaders() {
0353: return mimeHeaders.getAllHeaders();
0354: }
0355:
0356: /**
0357: * Retrieves all <CODE>MimeHeader</CODE> objects that match a name in the given array.
0358: *
0359: * @param names a <CODE>String</CODE> array with the name(s) of the MIME headers to be returned
0360: * @return all of the MIME headers that match one of the names in the given array, returned as
0361: * an <CODE>Iterator</CODE> object
0362: */
0363: public Iterator getMatchingMimeHeaders(String[] names) {
0364: return mimeHeaders.getMatchingHeaders(names);
0365: }
0366:
0367: /**
0368: * Retrieves all <CODE>MimeHeader</CODE> objects whose name does not match a name in the given
0369: * array.
0370: *
0371: * @param names a <CODE>String</CODE> array with the name(s) of the MIME headers not to be
0372: * returned
0373: * @return all of the MIME headers in this <CODE>SOAPPart</CODE> object except those that match
0374: * one of the names in the given array. The nonmatching MIME headers are returned as an
0375: * <CODE>Iterator</CODE> object.
0376: */
0377: public Iterator getNonMatchingMimeHeaders(String[] names) {
0378: return mimeHeaders.getNonMatchingHeaders(names);
0379: }
0380:
0381: public void setContent(Source source) throws SOAPException {
0382: this .source = source;
0383: try {
0384: ByteArrayOutputStream baos = new ByteArrayOutputStream();
0385:
0386: XMLInputFactory inputFactory = XMLInputFactory
0387: .newInstance();
0388: XMLStreamReader reader;
0389:
0390: if (source instanceof StreamSource) {
0391: reader = inputFactory.createXMLStreamReader(source);
0392: } else {
0393: Result result = new StreamResult(baos);
0394: Transformer xformer = TransformerFactory.newInstance()
0395: .newTransformer();
0396: xformer.transform(source, result);
0397: InputStream is = new ByteArrayInputStream(baos
0398: .toByteArray());
0399: reader = inputFactory.createXMLStreamReader(is);
0400: }
0401:
0402: StAXSOAPModelBuilder builder1 = null;
0403: if (this .envelope.element.getOMFactory() instanceof SOAP11Factory) {
0404: builder1 = new StAXSOAPModelBuilder(reader,
0405: (SOAP11Factory) this .envelope.element
0406: .getOMFactory(), null);
0407: } else if (this .envelope.element.getOMFactory() instanceof SOAP12Factory) {
0408: builder1 = new StAXSOAPModelBuilder(reader,
0409: (SOAP12Factory) this .envelope.element
0410: .getOMFactory(), null);
0411: }
0412:
0413: org.apache.axiom.soap.SOAPEnvelope soapEnvelope = builder1
0414: .getSOAPEnvelope();
0415: envelope = new SOAPEnvelopeImpl(
0416: (org.apache.axiom.soap.impl.dom.SOAPEnvelopeImpl) soapEnvelope);
0417: envelope.element.build();
0418: this .document = envelope.getOwnerDocument();
0419: } catch (TransformerFactoryConfigurationError e) {
0420: log.error(e);
0421: throw new SOAPException(e);
0422: } catch (Exception e) {
0423: log.error(e);
0424: throw new SOAPException(e);
0425: }
0426: }
0427:
0428: /**
0429: * Returns the content of the SOAPEnvelope as a JAXP <CODE> Source</CODE> object.
0430: *
0431: * @return the content as a <CODE> javax.xml.transform.Source</CODE> object
0432: * @throws SOAPException if the implementation cannot convert the specified <CODE>Source</CODE>
0433: * object
0434: * @see #setContent(javax.xml.transform.Source) setContent(javax.xml.transform.Source)
0435: */
0436: public Source getContent() throws SOAPException {
0437: DOMSource domSource = new DOMSource(this .document);
0438: this .source = domSource;
0439: return source;
0440: }
0441:
0442: /**
0443: * The Document Type Declaration (see <code>DocumentType</code>) associated with this document.
0444: * For HTML documents as well as XML documents without a document type declaration this returns
0445: * <code>null</code>. The DOM Level 2 does not support editing the Document Type Declaration.
0446: * <code>docType</code> cannot be altered in any way, including through the use of methods
0447: * inherited from the <code>Node</code> interface, such as <code>insertNode</code> or
0448: * <code>removeNode</code>.
0449: */
0450: public DocumentType getDoctype() {
0451: return document.getDoctype();
0452: }
0453:
0454: /**
0455: * The <code>DOMImplementation</code> object that handles this document. A DOM application may
0456: * use objects from multiple implementations.
0457: */
0458: public DOMImplementation getImplementation() {
0459: return document.getImplementation();
0460: }
0461:
0462: /**
0463: * This is a convenience attribute that allows direct access to the child node that is the root
0464: * element of the document. For HTML documents, this is the element with the tagName "HTML".
0465: */
0466: public Element getDocumentElement() {
0467: return document.getDocumentElement();
0468: }
0469:
0470: /**
0471: * Creates an element of the type specified. Note that the instance returned implements the
0472: * <code>Element</code> interface, so attributes can be specified directly on the returned
0473: * object. <br>In addition, if there are known attributes with default values, <code>Attr</code>
0474: * nodes representing them are automatically created and attached to the element. <br>To create
0475: * an element with a qualified name and namespace URI, use the <code>createElementNS</code>
0476: * method.
0477: *
0478: * @param tagName The name of the element type to instantiate. For XML, this is case-sensitive.
0479: * For HTML, the <code>tagName</code> parameter may be provided in any case, but
0480: * it must be mapped to the canonical uppercase form by the DOM implementation.
0481: * @return A new <code>Element</code> object with the <code>nodeName</code> attribute set to
0482: * <code>tagName</code>, and <code>localName</code>, <code>prefix</code>, and
0483: * <code>namespaceURI</code> set to <code>null</code>.
0484: * @throws DOMException INVALID_CHARACTER_ERR: Raised if the specified name contains an illegal
0485: * character.
0486: */
0487: public Element createElement(String tagName) throws DOMException {
0488: return document.createElement(tagName);
0489: }
0490:
0491: /**
0492: * Creates an empty <code>DocumentFragment</code> object.
0493: *
0494: * @return A new <code>DocumentFragment</code>.
0495: */
0496: public DocumentFragment createDocumentFragment() {
0497: return document.createDocumentFragment();
0498: }
0499:
0500: /**
0501: * Creates a <code>Text</code> node given the specified string.
0502: *
0503: * @param data The data for the node.
0504: * @return The new <code>Text</code> object.
0505: */
0506: public Text createTextNode(String data) {
0507: return document.createTextNode(data);
0508: }
0509:
0510: /**
0511: * Creates a <code>CDATASection</code> node whose value is the specified string.
0512: *
0513: * @param data The data for the <code>CDATASection</code> contents.
0514: * @return The new <code>CDATASection</code> object.
0515: * @throws DOMException NOT_SUPPORTED_ERR: Raised if this document is an HTML document.
0516: */
0517: public Comment createComment(String data) {
0518: return document.createComment(data);
0519: }
0520:
0521: /**
0522: * Creates a <code>CDATASection</code> node whose value is the specified string.
0523: *
0524: * @param data The data for the <code>CDATASection</code> contents.
0525: * @return The new <code>CDATASection</code> object.
0526: * @throws DOMException NOT_SUPPORTED_ERR: Raised if this document is an HTML document.
0527: */
0528: public CDATASection createCDATASection(String data)
0529: throws DOMException {
0530: return document.createCDATASection(data);
0531: }
0532:
0533: /**
0534: * Creates a <code>ProcessingInstruction</code> node given the specified name and data strings.
0535: *
0536: * @param target The target part of the processing instruction.
0537: * @param data The data for the node.
0538: * @return The new <code>ProcessingInstruction</code> object.
0539: * @throws DOMException INVALID_CHARACTER_ERR: Raised if the specified target contains an
0540: * illegal character. <br>NOT_SUPPORTED_ERR: Raised if this document is an
0541: * HTML document.
0542: */
0543: public ProcessingInstruction createProcessingInstruction(
0544: String target, String data) throws DOMException {
0545: return document.createProcessingInstruction(target, data);
0546: }
0547:
0548: /**
0549: * Creates an <code>Attr</code> of the given name. Note that the <code>Attr</code> instance can
0550: * then be set on an <code>Element</code> using the <code>setAttributeNode</code> method. <br>To
0551: * create an attribute with a qualified name and namespace URI, use the
0552: * <code>createAttributeNS</code> method.
0553: *
0554: * @param name The name of the attribute.
0555: * @return A new <code>Attr</code> object with the <code>nodeName</code> attribute set to
0556: * <code>name</code>, and <code>localName</code>, <code>prefix</code>, and
0557: * <code>namespaceURI</code> set to <code>null</code>. The value of the attribute is the
0558: * empty string.
0559: * @throws DOMException INVALID_CHARACTER_ERR: Raised if the specified name contains an illegal
0560: * character.
0561: */
0562: public Attr createAttribute(String name) throws DOMException {
0563: return document.createAttribute(name);
0564: }
0565:
0566: /**
0567: * Creates an <code>EntityReference</code> object. In addition, if the referenced entity is
0568: * known, the child list of the <code>EntityReference</code> node is made the same as that of
0569: * the corresponding <code>Entity</code> node.If any descendant of the <code>Entity</code> node
0570: * has an unbound namespace prefix, the corresponding descendant of the created
0571: * <code>EntityReference</code> node is also unbound; (its <code>namespaceURI</code> is
0572: * <code>null</code>). The DOM Level 2 does not support any mechanism to resolve namespace
0573: * prefixes.
0574: *
0575: * @param name The name of the entity to reference.
0576: * @return The new <code>EntityReference</code> object.
0577: * @throws DOMException INVALID_CHARACTER_ERR: Raised if the specified name contains an illegal
0578: * character. <br>NOT_SUPPORTED_ERR: Raised if this document is an HTML
0579: * document.
0580: */
0581: public EntityReference createEntityReference(String name)
0582: throws DOMException {
0583: return document.createEntityReference(name);
0584: }
0585:
0586: /**
0587: * Returns a <code>NodeList</code> of all the <code>Elements</code> with a given tag name in the
0588: * order in which they are encountered in a preorder traversal of the <code>Document</code>
0589: * tree.
0590: *
0591: * @param tagname The name of the tag to match on. The special value "*" matches all tags.
0592: * @return A new <code>NodeList</code> object containing all the matched <code>Elements</code>.
0593: */
0594: public NodeList getElementsByTagName(String tagname) {
0595: return document.getElementsByTagName(tagname);
0596: }
0597:
0598: /**
0599: * Imports a node from another document to this document. The returned node has no parent;
0600: * (<code>parentNode</code> is <code>null</code>). The source node is not altered or removed
0601: * from the original document; this method creates a new copy of the source node. <br>For all
0602: * nodes, importing a node creates a node object owned by the importing document, with attribute
0603: * values identical to the source node's <code>nodeName</code> and <code>nodeType</code>, plus
0604: * the attributes related to namespaces (<code>prefix</code>, <code>localName</code>, and
0605: * <code>namespaceURI</code>). As in the <code>cloneNode</code> operation on a
0606: * <code>Node</code>, the source node is not altered. <br>Additional information is copied as
0607: * appropriate to the <code>nodeType</code>, attempting to mirror the behavior expected if a
0608: * fragment of XML or HTML source was copied from one document to another, recognizing that the
0609: * two documents may have different DTDs in the XML case. The following list describes the
0610: * specifics for each type of node. <dl> <dt>ATTRIBUTE_NODE</dt> <dd>The
0611: * <code>ownerElement</code> attribute is set to <code>null</code> and the
0612: * <code>specified</code> flag is set to <code>true</code> on the generated <code>Attr</code>.
0613: * The descendants of the source <code>Attr</code> are recursively imported and the resulting
0614: * nodes reassembled to form the corresponding subtree. Note that the <code>deep</code>
0615: * parameter has no effect on <code>Attr</code> nodes; they always carry their children with
0616: * them when imported.</dd> <dt>DOCUMENT_FRAGMENT_NODE</dt> <dd>If the <code>deep</code> option
0617: * was set to <code>true</code>, the descendants of the source element are recursively imported
0618: * and the resulting nodes reassembled to form the corresponding subtree. Otherwise, this simply
0619: * generates an empty <code>DocumentFragment</code>.</dd> <dt>DOCUMENT_NODE</dt>
0620: * <dd><code>Document</code> nodes cannot be imported.</dd> <dt>DOCUMENT_TYPE_NODE</dt>
0621: * <dd><code>DocumentType</code> nodes cannot be imported.</dd> <dt>ELEMENT_NODE</dt>
0622: * <dd>Specified attribute nodes of the source element are imported, and the generated
0623: * <code>Attr</code> nodes are attached to the generated <code>Element</code>. Default
0624: * attributes are not copied, though if the document being imported into defines default
0625: * attributes for this element name, those are assigned. If the <code>importNode</code>
0626: * <code>deep</code> parameter was set to <code>true</code>, the descendants of the source
0627: * element are recursively imported and the resulting nodes reassembled to form the
0628: * corresponding subtree.</dd> <dt>ENTITY_NODE</dt> <dd><code>Entity</code> nodes can be
0629: * imported, however in the current release of the DOM the <code>DocumentType</code> is
0630: * readonly. Ability to add these imported nodes to a <code>DocumentType</code> will be
0631: * considered for addition to a future release of the DOM.On import, the <code>publicId</code>,
0632: * <code>systemId</code>, and <code>notationName</code> attributes are copied. If a
0633: * <code>deep</code> import is requested, the descendants of the the source <code>Entity</code>
0634: * are recursively imported and the resulting nodes reassembled to form the corresponding
0635: * subtree.</dd> <dt> ENTITY_REFERENCE_NODE</dt> <dd>Only the <code>EntityReference</code>
0636: * itself is copied, even if a <code>deep</code> import is requested, since the source and
0637: * destination documents might have defined the entity differently. If the document being
0638: * imported into provides a definition for this entity name, its value is assigned.</dd>
0639: * <dt>NOTATION_NODE</dt> <dd> <code>Notation</code> nodes can be imported, however in the
0640: * current release of the DOM the <code>DocumentType</code> is readonly. Ability to add these
0641: * imported nodes to a <code>DocumentType</code> will be considered for addition to a future
0642: * release of the DOM.On import, the <code>publicId</code> and <code>systemId</code> attributes
0643: * are copied. Note that the <code>deep</code> parameter has no effect on <code>Notation</code>
0644: * nodes since they never have any children.</dd> <dt> PROCESSING_INSTRUCTION_NODE</dt> <dd>The
0645: * imported node copies its <code>target</code> and <code>data</code> values from those of the
0646: * source node.</dd> <dt>TEXT_NODE, CDATA_SECTION_NODE, COMMENT_NODE</dt> <dd>These three types
0647: * of nodes inheriting from <code>CharacterData</code> copy their <code>data</code> and
0648: * <code>length</code> attributes from those of the source node.</dd> </dl>
0649: *
0650: * @param importedNode The node to import.
0651: * @param deep If <code>true</code>, recursively import the subtree under the specified
0652: * node; if <code>false</code>, import only the node itself, as explained
0653: * above. This has no effect on <code>Attr</code> , <code>EntityReference</code>,
0654: * and <code>Notation</code> nodes.
0655: * @return The imported node that belongs to this <code>Document</code>.
0656: * @throws DOMException NOT_SUPPORTED_ERR: Raised if the type of node being imported is not
0657: * supported.
0658: * @since DOM Level 2
0659: */
0660: public Node importNode(Node importedNode, boolean deep)
0661: throws DOMException {
0662: return document.importNode(importedNode, deep);
0663: }
0664:
0665: /**
0666: * Creates an element of the given qualified name and namespace URI.
0667: *
0668: * @param namespaceURI The namespace URI of the element to create.
0669: * @param qualifiedName The qualified name of the element type to instantiate.
0670: * @return A new <code>Element</code> object with the following attributes: <table border='1'
0671: * summary="Description of attributes and values for the new Element object"> <tr>
0672: * <th>Attribute</th> <th>Value</th> </tr> <tr> <td valign='top'><code>Node.nodeName</code></td>
0673: * <td valign='top'> <code>qualifiedName</code></td> </tr> <tr> <td
0674: * valign='top'><code>Node.namespaceURI</code></td> <td valign='top'>
0675: * <code>namespaceURI</code></td> </tr> <tr> <td valign='top'><code>Node.prefix</code></td>
0676: * <td valign='top'>prefix, extracted from <code>qualifiedName</code>, or
0677: * <code>null</code> if there is no prefix</td> </tr> <tr> <td
0678: * valign='top'><code>Node.localName</code></td> <td valign='top'>local name, extracted
0679: * from <code>qualifiedName</code></td> </tr> <tr> <td valign='top'><code>Element.tagName</code></td>
0680: * <td valign='top'> <code>qualifiedName</code></td> </tr> </table>
0681: * @throws DOMException INVALID_CHARACTER_ERR: Raised if the specified qualified name contains
0682: * an illegal character, per the XML 1.0 specification . <br>NAMESPACE_ERR:
0683: * Raised if the <code>qualifiedName</code> is malformed per the Namespaces
0684: * in XML specification, if the <code>qualifiedName</code> has a prefix and
0685: * the <code>namespaceURI</code> is <code>null</code>, or if the
0686: * <code>qualifiedName</code> has a prefix that is "xml" and the
0687: * <code>namespaceURI</code> is different from " http://www.w3.org/XML/1998/namespace"
0688: * . <br>NOT_SUPPORTED_ERR: Always thrown if the current document does not
0689: * support the <code>"XML"</code> feature, since namespaces were defined by
0690: * XML.
0691: * @since DOM Level 2
0692: */
0693: public Element createElementNS(String namespaceURI,
0694: String qualifiedName) throws DOMException {
0695: return document.createElementNS(namespaceURI, qualifiedName);
0696: }
0697:
0698: /**
0699: * Creates an attribute of the given qualified name and namespace URI.
0700: *
0701: * @param namespaceURI The namespace URI of the attribute to create.
0702: * @param qualifiedName The qualified name of the attribute to instantiate.
0703: * @return A new <code>Attr</code> object with the following attributes: <table border='1'
0704: * summary="Description of attributes and values for the new Attr object"> <tr> <th>
0705: * Attribute</th> <th>Value</th> </tr> <tr> <td valign='top'><code>Node.nodeName</code></td>
0706: * <td valign='top'>qualifiedName</td> </tr> <tr> <td valign='top'>
0707: * <code>Node.namespaceURI</code></td> <td valign='top'><code>namespaceURI</code></td>
0708: * </tr> <tr> <td valign='top'> <code>Node.prefix</code></td> <td valign='top'>prefix,
0709: * extracted from <code>qualifiedName</code>, or <code>null</code> if there is no
0710: * prefix</td> </tr> <tr> <td valign='top'><code>Node.localName</code></td> <td
0711: * valign='top'>local name, extracted from <code>qualifiedName</code></td> </tr> <tr>
0712: * <td valign='top'><code>Attr.name</code></td> <td valign='top'>
0713: * <code>qualifiedName</code></td> </tr> <tr> <td valign='top'><code>Node.nodeValue</code></td>
0714: * <td valign='top'>the empty string</td> </tr> </table>
0715: * @throws DOMException INVALID_CHARACTER_ERR: Raised if the specified qualified name contains
0716: * an illegal character, per the XML 1.0 specification . <br>NAMESPACE_ERR:
0717: * Raised if the <code>qualifiedName</code> is malformed per the Namespaces
0718: * in XML specification, if the <code>qualifiedName</code> has a prefix and
0719: * the <code>namespaceURI</code> is <code>null</code>, if the
0720: * <code>qualifiedName</code> has a prefix that is "xml" and the
0721: * <code>namespaceURI</code> is different from " http://www.w3.org/XML/1998/namespace",
0722: * or if the <code>qualifiedName</code>, or its prefix, is "xmlns" and the
0723: * <code>namespaceURI</code> is different from " http://www.w3.org/2000/xmlns/".
0724: * <br>NOT_SUPPORTED_ERR: Always thrown if the current document does not
0725: * support the <code>"XML"</code> feature, since namespaces were defined by
0726: * XML.
0727: * @since DOM Level 2
0728: */
0729: public Attr createAttributeNS(String namespaceURI,
0730: String qualifiedName) throws DOMException {
0731: return document.createAttributeNS(namespaceURI, qualifiedName);
0732: }
0733:
0734: /**
0735: * Returns a <code>NodeList</code> of all the <code>Elements</code> with a given local name and
0736: * namespace URI in the order in which they are encountered in a preorder traversal of the
0737: * <code>Document</code> tree.
0738: *
0739: * @param namespaceURI The namespace URI of the elements to match on. The special value "*"
0740: * matches all namespaces.
0741: * @param localName The local name of the elements to match on. The special value "*" matches
0742: * all local names.
0743: * @return A new <code>NodeList</code> object containing all the matched <code>Elements</code>.
0744: * @since DOM Level 2
0745: */
0746: public NodeList getElementsByTagNameNS(String namespaceURI,
0747: String localName) {
0748: return document.getElementsByTagNameNS(namespaceURI, localName);
0749: }
0750:
0751: /**
0752: * Returns the <code>Element</code> whose <code>ID</code> is given by <code>elementId</code>. If
0753: * no such element exists, returns <code>null</code>. Behavior is not defined if more than one
0754: * element has this <code>ID</code>. The DOM implementation must have information that says
0755: * which attributes are of type ID. Attributes with the name "ID" are not of type ID unless so
0756: * defined. Implementations that do not know whether attributes are of type ID or not are
0757: * expected to return <code>null</code>.
0758: *
0759: * @param elementId The unique <code>id</code> value for an element.
0760: * @return The matching element.
0761: * @since DOM Level 2
0762: */
0763: public Element getElementById(String elementId) {
0764: return document.getElementById(elementId);
0765: }
0766:
0767: public String getInputEncoding() {
0768: //return ((DeferredDocumentImpl)(((DOMSource)this.source).getNode())).getInputEncoding();
0769: return this .envelope.getEncodingStyle();
0770: }
0771:
0772: public String getXmlEncoding() {
0773: return document.getXmlEncoding();
0774: }
0775:
0776: public boolean getXmlStandalone() {
0777: return document.getXmlStandalone();
0778: }
0779:
0780: public void setXmlStandalone(boolean xmlStandalone)
0781: throws DOMException {
0782: document.setXmlStandalone(xmlStandalone);
0783: }
0784:
0785: public String getXmlVersion() {
0786: return document.getXmlVersion();
0787: }
0788:
0789: public void setXmlVersion(String xmlVersion) throws DOMException {
0790: document.setXmlVersion(xmlVersion);
0791: }
0792:
0793: public boolean getStrictErrorChecking() {
0794: return document.getStrictErrorChecking();
0795: }
0796:
0797: public void setStrictErrorChecking(boolean strictErrorChecking) {
0798: document.setStrictErrorChecking(strictErrorChecking);
0799: }
0800:
0801: public String getDocumentURI() {
0802: return document.getDocumentURI();
0803: }
0804:
0805: public void setDocumentURI(String documentURI) {
0806: document.setDocumentURI(documentURI);
0807: }
0808:
0809: public Node adoptNode(Node source) throws DOMException {
0810: return document.adoptNode(source);
0811: }
0812:
0813: public DOMConfiguration getDomConfig() {
0814: return document.getDomConfig();
0815: }
0816:
0817: public void normalizeDocument() {
0818: document.normalizeDocument();
0819: }
0820:
0821: public Node renameNode(Node n, String namespaceURI,
0822: String qualifiedName) throws DOMException {
0823: return document.renameNode(n, namespaceURI, qualifiedName);
0824: }
0825:
0826: /** The name of this node, depending on its type; see the table above. */
0827: public String getNodeName() {
0828: return document.getNodeName();
0829: }
0830:
0831: /**
0832: * The value of this node, depending on its type; see the table above. When it is defined to be
0833: * <code>null</code>, setting it has no effect.
0834: *
0835: * @throws DOMException NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
0836: * @throws DOMException DOMSTRING_SIZE_ERR: Raised when it would return more characters than fit
0837: * in a <code>DOMString</code> variable on the implementation platform.
0838: */
0839: public String getNodeValue() throws DOMException {
0840: return document.getNodeValue();
0841: }
0842:
0843: /**
0844: * The value of this node, depending on its type; see the table above. When it is defined to be
0845: * <code>null</code>, setting it has no effect.
0846: *
0847: * @throws DOMException NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
0848: * @throws DOMException DOMSTRING_SIZE_ERR: Raised when it would return more characters than fit
0849: * in a <code>DOMString</code> variable on the implementation platform.
0850: */
0851: public void setNodeValue(String arg0) throws DOMException {
0852: document.setNodeValue(arg0);
0853: }
0854:
0855: /** A code representing the type of the underlying object, as defined above. */
0856: public short getNodeType() {
0857: return document.getNodeType();
0858: }
0859:
0860: /**
0861: * The parent of this node. All nodes, except <code>Attr</code>, <code>Document</code>,
0862: * <code>DocumentFragment</code>, <code>Entity</code>, and <code>Notation</code> may have a
0863: * parent. However, if a node has just been created and not yet added to the tree, or if it has
0864: * been removed from the tree, this is <code>null</code>.
0865: */
0866: public Node getParentNode() {
0867: return document.getParentNode();
0868: }
0869:
0870: /**
0871: * A <code>NodeList</code> that contains all children of this node. If there are no children,
0872: * this is a <code>NodeList</code> containing no nodes.
0873: */
0874: public NodeList getChildNodes() {
0875: return document.getChildNodes();
0876: }
0877:
0878: /** The first child of this node. If there is no such node, this returns <code>null</code>. */
0879: public Node getFirstChild() {
0880: return document.getFirstChild();
0881: }
0882:
0883: /** The last child of this node. If there is no such node, this returns <code>null</code>. */
0884: public Node getLastChild() {
0885: return document.getLastChild();
0886: }
0887:
0888: /**
0889: * The node immediately preceding this node. If there is no such node, this returns
0890: * <code>null</code>.
0891: */
0892: public Node getPreviousSibling() {
0893: return document.getPreviousSibling();
0894: }
0895:
0896: /**
0897: * The node immediately following this node. If there is no such node, this returns
0898: * <code>null</code>.
0899: */
0900: public Node getNextSibling() {
0901: return document.getNextSibling();
0902: }
0903:
0904: /**
0905: * A <code>NamedNodeMap</code> containing the attributes of this node (if it is an
0906: * <code>Element</code>) or <code>null</code> otherwise.
0907: */
0908: public NamedNodeMap getAttributes() {
0909: return document.getAttributes();
0910: }
0911:
0912: /**
0913: * The <code>Document</code> object associated with this node. This is also the
0914: * <code>Document</code> object used to create new nodes. When this node is a
0915: * <code>Document</code> or a <code>DocumentType</code> which is not used with any
0916: * <code>Document</code> yet, this is <code>null</code>.
0917: */
0918: public Document getOwnerDocument() {
0919: return document.getOwnerDocument();
0920: }
0921:
0922: /**
0923: * Inserts the node <code>newChild</code> before the existing child node <code>refChild</code>.
0924: * If <code>refChild</code> is <code>null</code>, insert <code>newChild</code> at the end of the
0925: * list of children. <br>If <code>newChild</code> is a <code>DocumentFragment</code> object, all
0926: * of its children are inserted, in the same order, before <code>refChild</code>. If the
0927: * <code>newChild</code> is already in the tree, it is first removed.
0928: *
0929: * @param newChild The node to insert.
0930: * @param refChild The reference node, i.e., the node before which the new node must be
0931: * inserted.
0932: * @return The node being inserted.
0933: * @throws DOMException HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not
0934: * allow children of the type of the <code>newChild</code> node, or if the
0935: * node to insert is one of this node's ancestors or this node itself.
0936: * <br>WRONG_DOCUMENT_ERR: Raised if <code>newChild</code> was created from
0937: * a different document than the one that created this node.
0938: * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly or if
0939: * the parent of the node being inserted is readonly. <br>NOT_FOUND_ERR:
0940: * Raised if <code>refChild</code> is not a child of this node.
0941: */
0942: public Node insertBefore(Node newChild, Node refChild)
0943: throws DOMException {
0944: return document.insertBefore(newChild, refChild);
0945: }
0946:
0947: /**
0948: * Replaces the child node <code>oldChild</code> with <code>newChild</code> in the list of
0949: * children, and returns the <code>oldChild</code> node. <br>If <code>newChild</code> is a
0950: * <code>DocumentFragment</code> object, <code>oldChild</code> is replaced by all of the
0951: * <code>DocumentFragment</code> children, which are inserted in the same order. If the
0952: * <code>newChild</code> is already in the tree, it is first removed.
0953: *
0954: * @param newChild The new node to put in the child list.
0955: * @param oldChild The node being replaced in the list.
0956: * @return The node replaced.
0957: * @throws DOMException HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not
0958: * allow children of the type of the <code>newChild</code> node, or if the
0959: * node to put in is one of this node's ancestors or this node itself.
0960: * <br>WRONG_DOCUMENT_ERR: Raised if <code>newChild</code> was created from
0961: * a different document than the one that created this node.
0962: * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node or the parent of
0963: * the new node is readonly. <br>NOT_FOUND_ERR: Raised if
0964: * <code>oldChild</code> is not a child of this node.
0965: */
0966: public Node replaceChild(Node newChild, Node oldChild)
0967: throws DOMException {
0968: return document.replaceChild(newChild, oldChild);
0969: }
0970:
0971: /**
0972: * Removes the child node indicated by <code>oldChild</code> from the list of children, and
0973: * returns it.
0974: *
0975: * @param oldChild The node being removed.
0976: * @return The node removed.
0977: * @throws DOMException NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
0978: * <br>NOT_FOUND_ERR: Raised if <code>oldChild</code> is not a child of
0979: * this node.
0980: */
0981: public Node removeChild(Node oldChild) throws DOMException {
0982: return document.removeChild(oldChild);
0983: }
0984:
0985: /**
0986: * Adds the node <code>newChild</code> to the end of the list of children of this node. If the
0987: * <code>newChild</code> is already in the tree, it is first removed.
0988: *
0989: * @param newChild The node to add.If it is a <code>DocumentFragment</code> object, the entire
0990: * contents of the document fragment are moved into the child list of this node
0991: * @return The node added.
0992: * @throws DOMException HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not
0993: * allow children of the type of the <code>newChild</code> node, or if the
0994: * node to append is one of this node's ancestors or this node itself.
0995: * <br>WRONG_DOCUMENT_ERR: Raised if <code>newChild</code> was created from
0996: * a different document than the one that created this node.
0997: * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly or if
0998: * the previous parent of the node being inserted is readonly.
0999: */
1000: public Node appendChild(Node newChild) throws DOMException {
1001: return document.appendChild(newChild);
1002: }
1003:
1004: /**
1005: * Returns whether this node has any children.
1006: *
1007: * @return <code>true</code> if this node has any children, <code>false</code> otherwise.
1008: */
1009: public boolean hasChildNodes() {
1010: return document.hasChildNodes();
1011: }
1012:
1013: /**
1014: * Returns a duplicate of this node, i.e., serves as a generic copy constructor for nodes. The
1015: * duplicate node has no parent; ( <code>parentNode</code> is <code>null</code>.). <br>Cloning
1016: * an <code>Element</code> copies all attributes and their values, including those generated by
1017: * the XML processor to represent defaulted attributes, but this method does not copy any text
1018: * it contains unless it is a deep clone, since the text is contained in a child
1019: * <code>Text</code> node. Cloning an <code>Attribute</code> directly, as opposed to be cloned
1020: * as part of an <code>Element</code> cloning operation, returns a specified attribute (
1021: * <code>specified</code> is <code>true</code>). Cloning any other type of node simply returns a
1022: * copy of this node. <br>Note that cloning an immutable subtree results in a mutable copy, but
1023: * the children of an <code>EntityReference</code> clone are readonly . In addition, clones of
1024: * unspecified <code>Attr</code> nodes are specified. And, cloning <code>Document</code>,
1025: * <code>DocumentType</code>, <code>Entity</code>, and <code>Notation</code> nodes is
1026: * implementation dependent.
1027: *
1028: * @param deep If <code>true</code>, recursively clone the subtree under the specified node; if
1029: * <code>false</code>, clone only the node itself (and its attributes, if it is an
1030: * <code>Element</code>).
1031: * @return The duplicate node.
1032: */
1033: public Node cloneNode(boolean deep) {
1034: return document.cloneNode(deep);
1035: }
1036:
1037: /**
1038: * Puts all <code>Text</code> nodes in the full depth of the sub-tree underneath this
1039: * <code>Node</code>, including attribute nodes, into a "normal" form where only structure
1040: * (e.g., elements, comments, processing instructions, CDATA sections, and entity references)
1041: * separates <code>Text</code> nodes, i.e., there are neither adjacent <code>Text</code> nodes
1042: * nor empty <code>Text</code> nodes. This can be used to ensure that the DOM view of a document
1043: * is the same as if it were saved and re-loaded, and is useful when operations (such as
1044: * XPointer lookups) that depend on a particular document tree structure are to be used.In
1045: * cases where the document contains <code>CDATASections</code>, the normalize operation alone
1046: * may not be sufficient, since XPointers do not differentiate between <code>Text</code> nodes
1047: * and <code>CDATASection</code> nodes.
1048: */
1049: public void normalize() {
1050: document.normalize();
1051: }
1052:
1053: /**
1054: * Tests whether the DOM implementation implements a specific feature and that feature is
1055: * supported by this node.
1056: *
1057: * @param feature The name of the feature to test. This is the same name which can be passed to
1058: * the method <code>hasFeature</code> on <code>DOMImplementation</code>.
1059: * @param version This is the version number of the feature to test. In Level 2, version 1, this
1060: * is the string "2.0". If the version is not specified, supporting any version
1061: * of the feature will cause the method to return <code>true</code>.
1062: * @return Returns <code>true</code> if the specified feature is supported on this node,
1063: * <code>false</code> otherwise.
1064: * @since DOM Level 2
1065: */
1066: public boolean isSupported(String feature, String version) {
1067: return document.isSupported(feature, version);
1068: }
1069:
1070: /**
1071: * The namespace URI of this node, or <code>null</code> if it is unspecified. <br>This is not a
1072: * computed value that is the result of a namespace lookup based on an examination of the
1073: * namespace declarations in scope. It is merely the namespace URI given at creation time.
1074: * <br>For nodes of any type other than <code>ELEMENT_NODE</code> and
1075: * <code>ATTRIBUTE_NODE</code> and nodes created with a DOM Level 1 method, such as
1076: * <code>createElement</code> from the <code>Document</code> interface, this is always
1077: * <code>null</code>.Per the Namespaces in XML Specification an attribute does not inherit its
1078: * namespace from the element it is attached to. If an attribute is not explicitly given a
1079: * namespace, it simply has no namespace.
1080: *
1081: * @since DOM Level 2
1082: */
1083: public String getNamespaceURI() {
1084: return document.getNamespaceURI();
1085: }
1086:
1087: /**
1088: * The namespace prefix of this node, or <code>null</code> if it is unspecified. <br>Note that
1089: * setting this attribute, when permitted, changes the <code>nodeName</code> attribute, which
1090: * holds the qualified name, as well as the <code>tagName</code> and <code>name</code>
1091: * attributes of the <code>Element</code> and <code>Attr</code> interfaces, when applicable.
1092: * <br>Note also that changing the prefix of an attribute that is known to have a default value,
1093: * does not make a new attribute with the default value and the original prefix appear, since
1094: * the <code>namespaceURI</code> and <code>localName</code> do not change. <br>For nodes of any
1095: * type other than <code>ELEMENT_NODE</code> and <code>ATTRIBUTE_NODE</code> and nodes created
1096: * with a DOM Level 1 method, such as <code>createElement</code> from the <code>Document</code>
1097: * interface, this is always <code>null</code>.
1098: *
1099: * @throws DOMException INVALID_CHARACTER_ERR: Raised if the specified prefix contains an
1100: * illegal character, per the XML 1.0 specification .
1101: * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
1102: * <br>NAMESPACE_ERR: Raised if the specified <code>prefix</code> is
1103: * malformed per the Namespaces in XML specification, if the
1104: * <code>namespaceURI</code> of this node is <code>null</code>, if the
1105: * specified prefix is "xml" and the <code>namespaceURI</code> of this node
1106: * is different from "http://www.w3.org/XML/1998/namespace", if this node
1107: * is an attribute and the specified prefix is "xmlns" and the
1108: * <code>namespaceURI</code> of this node is different from "
1109: * http://www.w3.org/2000/xmlns/", or if this node is an attribute and the
1110: * <code>qualifiedName</code> of this node is "xmlns" .
1111: * @since DOM Level 2
1112: */
1113: public String getPrefix() {
1114: return document.getPrefix();
1115: }
1116:
1117: /**
1118: * The namespace prefix of this node, or <code>null</code> if it is unspecified. <br>Note that
1119: * setting this attribute, when permitted, changes the <code>nodeName</code> attribute, which
1120: * holds the qualified name, as well as the <code>tagName</code> and <code>name</code>
1121: * attributes of the <code>Element</code> and <code>Attr</code> interfaces, when applicable.
1122: * <br>Note also that changing the prefix of an attribute that is known to have a default value,
1123: * does not make a new attribute with the default value and the original prefix appear, since
1124: * the <code>namespaceURI</code> and <code>localName</code> do not change. <br>For nodes of any
1125: * type other than <code>ELEMENT_NODE</code> and <code>ATTRIBUTE_NODE</code> and nodes created
1126: * with a DOM Level 1 method, such as <code>createElement</code> from the <code>Document</code>
1127: * interface, this is always <code>null</code>.
1128: *
1129: * @throws DOMException INVALID_CHARACTER_ERR: Raised if the specified prefix contains an
1130: * illegal character, per the XML 1.0 specification .
1131: * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
1132: * <br>NAMESPACE_ERR: Raised if the specified <code>prefix</code> is
1133: * malformed per the Namespaces in XML specification, if the
1134: * <code>namespaceURI</code> of this node is <code>null</code>, if the
1135: * specified prefix is "xml" and the <code>namespaceURI</code> of this node
1136: * is different from "http://www.w3.org/XML/1998/namespace", if this node
1137: * is an attribute and the specified prefix is "xmlns" and the
1138: * <code>namespaceURI</code> of this node is different from "
1139: * http://www.w3.org/2000/xmlns/", or if this node is an attribute and the
1140: * <code>qualifiedName</code> of this node is "xmlns" .
1141: * @since DOM Level 2
1142: */
1143: public void setPrefix(String arg0) throws DOMException {
1144: document.setPrefix(arg0);
1145: }
1146:
1147: /**
1148: * Returns the local part of the qualified name of this node. <br>For nodes of any type other
1149: * than <code>ELEMENT_NODE</code> and <code>ATTRIBUTE_NODE</code> and nodes created with a DOM
1150: * Level 1 method, such as <code>createElement</code> from the <code>Document</code> interface,
1151: * this is always <code>null</code>.
1152: *
1153: * @since DOM Level 2
1154: */
1155: public String getLocalName() {
1156: return document.getLocalName();
1157: }
1158:
1159: /**
1160: * Returns whether this node (if it is an element) has any attributes.
1161: *
1162: * @return <code>true</code> if this node has any attributes, <code>false</code> otherwise.
1163: * @since DOM Level 2
1164: */
1165: public boolean hasAttributes() {
1166: return document.hasAttributes();
1167: }
1168:
1169: protected void setMessage(SOAPMessageImpl message) {
1170: soapMessage = message;
1171: }
1172:
1173: /*
1174: * DOM-Level 3 methods
1175: */
1176:
1177: public String getBaseURI() {
1178: return document.getBaseURI();
1179: }
1180:
1181: public short compareDocumentPosition(Node node) throws DOMException {
1182: return document.compareDocumentPosition(node);
1183: }
1184:
1185: public String getTextContent() throws DOMException {
1186: return document.getTextContent();
1187: }
1188:
1189: public void setTextContent(String textContent) throws DOMException {
1190: document.setTextContent(textContent);
1191: }
1192:
1193: public boolean isSameNode(Node other) {
1194: return document.isSameNode(other);
1195: }
1196:
1197: public String lookupPrefix(String namespaceURI) {
1198: return document.lookupPrefix(namespaceURI);
1199: }
1200:
1201: public boolean isDefaultNamespace(String namespaceURI) {
1202: return document.isDefaultNamespace(namespaceURI);
1203: }
1204:
1205: public String lookupNamespaceURI(String prefix) {
1206: return document.lookupNamespaceURI(prefix);
1207: }
1208:
1209: public boolean isEqualNode(Node node) {
1210: return document.isEqualNode(node);
1211: }
1212:
1213: public Object getFeature(String feature, String version) {
1214: return document.getFeature(feature, version);
1215: }
1216:
1217: public Object setUserData(String key, Object data,
1218: UserDataHandler handler) {
1219: return document.setUserData(key, data, handler);
1220: }
1221:
1222: public Object getUserData(String key) {
1223: return document.getUserData(key);
1224: }
1225:
1226: public String getValue() {
1227: //There are no immediate child text nodes to soap part
1228: return null;
1229: }
1230:
1231: public void setParentElement(SOAPElement parent)
1232: throws SOAPException {
1233: throw new SOAPException(
1234: "Cannot set the parent element of SOAPPart");
1235: }
1236:
1237: public SOAPElement getParentElement() {
1238: return null; //SOAP part is the root element
1239: }
1240:
1241: public void detachNode() {
1242: //nothing to do here
1243: }
1244:
1245: public void recycleNode() {
1246: //nothing to do here
1247: }
1248:
1249: public void setValue(String value) {
1250: throw new IllegalStateException("Cannot set value of SOAPPart.");
1251: }
1252: }
|