jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/messaging/saaj/soap/impl/ElementImpl.java
changeset 43852 93a527059d8a
parent 43126 26c4004e8cc0
child 45678 65fdff10664d
equal deleted inserted replaced
43752:3c68ef249093 43852:93a527059d8a
    41 import com.sun.xml.internal.messaging.saaj.soap.SOAPDocument;
    41 import com.sun.xml.internal.messaging.saaj.soap.SOAPDocument;
    42 import com.sun.xml.internal.messaging.saaj.soap.SOAPDocumentImpl;
    42 import com.sun.xml.internal.messaging.saaj.soap.SOAPDocumentImpl;
    43 import com.sun.xml.internal.messaging.saaj.soap.name.NameImpl;
    43 import com.sun.xml.internal.messaging.saaj.soap.name.NameImpl;
    44 import com.sun.xml.internal.messaging.saaj.util.*;
    44 import com.sun.xml.internal.messaging.saaj.util.*;
    45 
    45 
    46 public class ElementImpl
    46 public class ElementImpl implements SOAPElement, SOAPBodyElement {
    47     extends com.sun.org.apache.xerces.internal.dom.ElementNSImpl
       
    48     implements SOAPElement, SOAPBodyElement {
       
    49 
    47 
    50     public static final String DSIG_NS = "http://www.w3.org/2000/09/xmldsig#".intern();
    48     public static final String DSIG_NS = "http://www.w3.org/2000/09/xmldsig#".intern();
    51     public static final String XENC_NS = "http://www.w3.org/2001/04/xmlenc#".intern();
    49     public static final String XENC_NS = "http://www.w3.org/2001/04/xmlenc#".intern();
    52     public static final String WSU_NS = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd".intern();
    50     public static final String WSU_NS = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd".intern();
    53 
    51 
    54     private transient AttributeManager encodingStyleAttribute = new AttributeManager();
    52     private transient AttributeManager encodingStyleAttribute = new AttributeManager();
    55 
    53 
    56     protected QName elementQName;
    54     protected QName elementQName;
       
    55 
       
    56     private Element element;
       
    57 
       
    58     private SOAPDocumentImpl soapDocument;
       
    59 
       
    60     @Override
       
    61     public String getTagName() {
       
    62         return element.getTagName();
       
    63     }
       
    64 
       
    65     @Override
       
    66     public String getAttribute(String name) {
       
    67         return element.getAttribute(name);
       
    68     }
       
    69 
       
    70     @Override
       
    71     public void setAttribute(String name, String value) throws DOMException {
       
    72         boolean isQualifiedName = (name.indexOf(":") > 0);
       
    73         //this is because of BugfixTest#testCR7020991, after removal internal dependencies
       
    74         //SOAPDocumentImpl#createAttribute is not called anymore from xerces parent
       
    75         if (isQualifiedName) {
       
    76             String nsUri = null;
       
    77             String prefix = name.substring(0, name.indexOf(":"));
       
    78             //cannot do anything to resolve the URI if prefix is not
       
    79             //XMLNS.
       
    80             if (XMLNS.equals(prefix)) {
       
    81                 nsUri = ElementImpl.XMLNS_URI;
       
    82                 setAttributeNS(nsUri, name, value);
       
    83                 return;
       
    84             }
       
    85         }
       
    86         element.setAttribute(name, value);
       
    87     }
       
    88 
       
    89     @Override
       
    90     public void removeAttribute(String name) throws DOMException {
       
    91         element.removeAttribute(name);
       
    92     }
       
    93 
       
    94     @Override
       
    95     public Attr getAttributeNode(String name) {
       
    96         return element.getAttributeNode(name);
       
    97     }
       
    98 
       
    99     @Override
       
   100     public Attr setAttributeNode(Attr newAttr) throws DOMException {
       
   101         return element.setAttributeNode(newAttr);
       
   102     }
       
   103 
       
   104     @Override
       
   105     public Attr removeAttributeNode(Attr oldAttr) throws DOMException {
       
   106         return element.removeAttributeNode(oldAttr);
       
   107     }
       
   108 
       
   109     @Override
       
   110     public NodeList getElementsByTagName(String name) {
       
   111         return new NodeListImpl(getSoapDocument(), element.getElementsByTagName(name));
       
   112     }
       
   113 
       
   114     @Override
       
   115     public String getAttributeNS(String namespaceURI, String localName) throws DOMException {
       
   116         return element.getAttributeNS(namespaceURI, localName);
       
   117     }
    57 
   118 
    58     protected static final Logger log =
   119     protected static final Logger log =
    59         Logger.getLogger(LogDomainConstants.SOAP_IMPL_DOMAIN,
   120         Logger.getLogger(LogDomainConstants.SOAP_IMPL_DOMAIN,
    60                          "com.sun.xml.internal.messaging.saaj.soap.impl.LocalStrings");
   121                          "com.sun.xml.internal.messaging.saaj.soap.impl.LocalStrings");
    61 
   122 
    70      * The XML Namespace ("http://www.w3.org/XML/1998/namespace"). This is
   131      * The XML Namespace ("http://www.w3.org/XML/1998/namespace"). This is
    71      * the Namespace URI that is automatically mapped to the "xml" prefix.
   132      * the Namespace URI that is automatically mapped to the "xml" prefix.
    72      */
   133      */
    73     public final static String XML_URI = "http://www.w3.org/XML/1998/namespace".intern();
   134     public final static String XML_URI = "http://www.w3.org/XML/1998/namespace".intern();
    74 
   135 
       
   136     private final static String XMLNS = "xmlns".intern();
       
   137 
    75     public ElementImpl(SOAPDocumentImpl ownerDoc, Name name) {
   138     public ElementImpl(SOAPDocumentImpl ownerDoc, Name name) {
    76         super(
   139         this.soapDocument = ownerDoc;
    77             ownerDoc,
   140         this.element = ownerDoc.getDomDocument().createElementNS(name.getURI(), name.getQualifiedName());
    78             name.getURI(),
       
    79             name.getQualifiedName(),
       
    80             name.getLocalName());
       
    81         elementQName = NameImpl.convertToQName(name);
   141         elementQName = NameImpl.convertToQName(name);
       
   142         getSoapDocument().register(this);
    82     }
   143     }
    83 
   144 
    84     public ElementImpl(SOAPDocumentImpl ownerDoc, QName name) {
   145     public ElementImpl(SOAPDocumentImpl ownerDoc, QName name) {
    85         super(
   146         this.soapDocument = ownerDoc;
    86             ownerDoc,
   147         this.element = ownerDoc.getDomDocument().createElementNS(name.getNamespaceURI(), getQualifiedName(name));
    87             name.getNamespaceURI(),
       
    88             getQualifiedName(name),
       
    89             name.getLocalPart());
       
    90         elementQName = name;
   148         elementQName = name;
       
   149         getSoapDocument().register(this);
       
   150     }
       
   151 
       
   152     public ElementImpl(SOAPDocumentImpl ownerDoc, Element domElement) {
       
   153         this.element = domElement;
       
   154         this.soapDocument = ownerDoc;
       
   155         this.elementQName = new QName(domElement.getNamespaceURI(), domElement.getLocalName());
       
   156         getSoapDocument().register(this);
    91     }
   157     }
    92 
   158 
    93     public ElementImpl(
   159     public ElementImpl(
    94         SOAPDocumentImpl ownerDoc,
   160         SOAPDocumentImpl ownerDoc,
    95         String uri,
   161         String uri,
    96         String qualifiedName) {
   162         String qualifiedName) {
    97 
   163 
    98         super(ownerDoc, uri, qualifiedName);
   164         this.soapDocument = ownerDoc;
       
   165         this.element = ownerDoc.getDomDocument().createElementNS(uri, qualifiedName);
    99         elementQName =
   166         elementQName =
   100             new QName(uri, getLocalPart(qualifiedName), getPrefix(qualifiedName));
   167             new QName(uri, getLocalPart(qualifiedName), getPrefix(qualifiedName));
       
   168         getSoapDocument().register(this);
   101     }
   169     }
   102 
   170 
   103     public void ensureNamespaceIsDeclared(String prefix, String uri) {
   171     public void ensureNamespaceIsDeclared(String prefix, String uri) {
   104         String alreadyDeclaredUri = getNamespaceURI(prefix);
   172         String alreadyDeclaredUri = getNamespaceURI(prefix);
   105         if (alreadyDeclaredUri == null || !alreadyDeclaredUri.equals(uri)) {
   173         if (alreadyDeclaredUri == null || !alreadyDeclaredUri.equals(uri)) {
   109             }
   177             }
   110         }
   178         }
   111     }
   179     }
   112 
   180 
   113     public Document getOwnerDocument() {
   181     public Document getOwnerDocument() {
   114         Document doc = super.getOwnerDocument();
   182         return soapDocument;
   115         if (doc instanceof SOAPDocument)
   183     }
   116             return ((SOAPDocument) doc).getDocument();
   184 
   117         else
   185     @Override
   118             return doc;
   186     public Node insertBefore(Node newChild, Node refChild) throws DOMException {
       
   187         return element.insertBefore(getSoapDocument().getDomNode(newChild), getSoapDocument().getDomNode(refChild));
       
   188     }
       
   189 
       
   190     @Override
       
   191     public Node replaceChild(Node newChild, Node oldChild) throws DOMException {
       
   192         return element.replaceChild(getSoapDocument().getDomNode(newChild), getSoapDocument().getDomNode(oldChild));
       
   193     }
       
   194 
       
   195     @Override
       
   196     public Node removeChild(Node oldChild) throws DOMException {
       
   197         return element.removeChild(getSoapDocument().getDomNode(oldChild));
       
   198     }
       
   199 
       
   200     @Override
       
   201     public Node appendChild(Node newChild) throws DOMException {
       
   202         return element.appendChild(getSoapDocument().getDomNode(newChild));
       
   203     }
       
   204 
       
   205     @Override
       
   206     public boolean hasChildNodes() {
       
   207         return element.hasChildNodes();
       
   208     }
       
   209 
       
   210     @Override
       
   211     public Node cloneNode(boolean deep) {
       
   212         return element.cloneNode(deep);
       
   213     }
       
   214 
       
   215     @Override
       
   216     public void normalize() {
       
   217         element.normalize();
       
   218     }
       
   219 
       
   220     @Override
       
   221     public boolean isSupported(String feature, String version) {
       
   222         return element.isSupported(feature, version);
       
   223     }
       
   224 
       
   225     @Override
       
   226     public String getNamespaceURI() {
       
   227         return element.getNamespaceURI();
       
   228     }
       
   229 
       
   230     @Override
       
   231     public String getPrefix() {
       
   232         return element.getPrefix();
       
   233     }
       
   234 
       
   235     @Override
       
   236     public void setPrefix(String prefix) throws DOMException {
       
   237         element.setPrefix(prefix);
       
   238     }
       
   239 
       
   240     @Override
       
   241     public String getLocalName() {
       
   242         return element.getLocalName();
       
   243     }
       
   244 
       
   245     @Override
       
   246     public boolean hasAttributes() {
       
   247         return element.hasAttributes();
       
   248     }
       
   249 
       
   250     @Override
       
   251     public String getBaseURI() {
       
   252         return element.getBaseURI();
       
   253     }
       
   254 
       
   255     @Override
       
   256     public short compareDocumentPosition(Node other) throws DOMException {
       
   257         return element.compareDocumentPosition(other);
       
   258     }
       
   259 
       
   260     @Override
       
   261     public String getTextContent() throws DOMException {
       
   262         return element.getTextContent();
       
   263     }
       
   264 
       
   265     @Override
       
   266     public void setTextContent(String textContent) throws DOMException {
       
   267         element.setTextContent(textContent);
       
   268     }
       
   269 
       
   270     @Override
       
   271     public boolean isSameNode(Node other) {
       
   272         return element.isSameNode(other);
       
   273     }
       
   274 
       
   275     @Override
       
   276     public String lookupPrefix(String namespaceURI) {
       
   277         return element.lookupPrefix(namespaceURI);
       
   278     }
       
   279 
       
   280     @Override
       
   281     public boolean isDefaultNamespace(String namespaceURI) {
       
   282         return element.isDefaultNamespace(namespaceURI);
       
   283     }
       
   284 
       
   285     @Override
       
   286     public String lookupNamespaceURI(String prefix) {
       
   287         return element.lookupNamespaceURI(prefix);
       
   288     }
       
   289 
       
   290     @Override
       
   291     public boolean isEqualNode(Node arg) {
       
   292         return element.isEqualNode(arg);
       
   293     }
       
   294 
       
   295     @Override
       
   296     public Object getFeature(String feature, String version) {
       
   297         return element.getFeature(feature, version);
       
   298     }
       
   299 
       
   300     @Override
       
   301     public Object setUserData(String key, Object data, UserDataHandler handler) {
       
   302         return element.setUserData(key, data, handler);
       
   303     }
       
   304 
       
   305     @Override
       
   306     public Object getUserData(String key) {
       
   307         return element.getUserData(key);
   119     }
   308     }
   120 
   309 
   121     public SOAPElement addChildElement(Name name) throws SOAPException {
   310     public SOAPElement addChildElement(Name name) throws SOAPException {
   122         return  addElement(name);
   311         return  addElement(name);
   123     }
   312     }
   351         }
   540         }
   352 
   541 
   353         // preserve the encodingStyle attr as it may get lost in the import
   542         // preserve the encodingStyle attr as it may get lost in the import
   354         String encodingStyle = element.getEncodingStyle();
   543         String encodingStyle = element.getEncodingStyle();
   355 
   544 
   356         ElementImpl importedElement = (ElementImpl) importElement(element);
   545         final Element domElement = ((ElementImpl) element).getDomElement();
       
   546         final Element importedElement = importElement(domElement);
   357         addNode(importedElement);
   547         addNode(importedElement);
   358 
   548 
       
   549         final SOAPElement converted = convertToSoapElement(importedElement);
       
   550 
   359         if (encodingStyle != null)
   551         if (encodingStyle != null)
   360             importedElement.setEncodingStyle(encodingStyle);
   552             converted.setEncodingStyle(encodingStyle);
   361 
   553 
   362         return convertToSoapElement(importedElement);
   554         return converted;
   363     }
   555     }
   364 
   556 
   365     protected Element importElement(Element element) {
   557     protected Element importElement(Element element) {
   366         Document document = getOwnerDocument();
   558         Document document = getOwnerDocument();
   367         Document oldDocument = element.getOwnerDocument();
   559         Document oldDocument = element.getOwnerDocument();
   372         }
   564         }
   373     }
   565     }
   374 
   566 
   375     protected SOAPElement addElement(Name name) throws SOAPException {
   567     protected SOAPElement addElement(Name name) throws SOAPException {
   376         SOAPElement newElement = createElement(name);
   568         SOAPElement newElement = createElement(name);
   377         addNode(newElement);
   569         addNode(((ElementImpl) newElement).getDomElement());
   378         return newElement;
   570         return newElement;
   379     }
   571     }
   380 
   572 
   381     protected SOAPElement addElement(QName name) throws SOAPException {
   573     protected SOAPElement addElement(QName name) throws SOAPException {
   382         SOAPElement newElement = createElement(name);
   574         SOAPElement newElement = createElement(name);
   409                 getOwnerDocument().createElement(getQualifiedName(name));
   601                 getOwnerDocument().createElement(getQualifiedName(name));
   410         }
   602         }
   411     }
   603     }
   412 
   604 
   413     protected void addNode(org.w3c.dom.Node newElement) throws SOAPException {
   605     protected void addNode(org.w3c.dom.Node newElement) throws SOAPException {
   414         insertBefore(newElement, null);
   606         insertBefore(getSoapDocument().getDomNode(newElement), null);
   415 
   607 
   416         if (getOwnerDocument() instanceof DocumentFragment)
   608         if (getOwnerDocument() instanceof DocumentFragment)
   417             return;
   609             return;
   418 
   610 
   419         if (newElement instanceof ElementImpl) {
   611         if (newElement instanceof ElementImpl) {
   429 
   621 
   430     Element getFirstChildElement() {
   622     Element getFirstChildElement() {
   431         Node child = getFirstChild();
   623         Node child = getFirstChild();
   432         while (child != null) {
   624         while (child != null) {
   433             if (child instanceof Element) {
   625             if (child instanceof Element) {
   434                 return ((Element) child);
   626                 return (Element) getSoapDocument().find(child);
   435             }
   627             }
   436             child = child.getNextSibling();
   628             child = child.getNextSibling();
   437         }
   629         }
   438         return null;
   630         return null;
   439     }
   631     }
   440 
   632 
   441     protected SOAPElement findChild(NameImpl name) {
   633     protected SOAPElement findChild(NameImpl name) {
   442         Node eachChild = getFirstChild();
   634         Node eachChild = getFirstChild();
   443         while (eachChild != null) {
   635         while (eachChild != null) {
   444             if (eachChild instanceof SOAPElement) {
   636             if (eachChild instanceof Element) {
   445                 SOAPElement eachChildSoap = (SOAPElement) eachChild;
   637                 SOAPElement eachChildSoap = (SOAPElement) getSoapDocument().find(eachChild);
   446                 if (eachChildSoap.getElementName().equals(name)) {
   638                 if (eachChildSoap != null) {
   447                     return eachChildSoap;
   639                     if (eachChildSoap.getElementName().equals(name)) {
       
   640                         return eachChildSoap;
       
   641                     }
   448                 }
   642                 }
   449             }
   643             }
   450             eachChild = eachChild.getNextSibling();
   644             eachChild = eachChild.getNextSibling();
   451         }
   645         }
   452         return null;
   646         return null;
   472         return addText(text);
   666         return addText(text);
   473     }
   667     }
   474 
   668 
   475     protected SOAPElement addCDATA(String text) throws SOAPException {
   669     protected SOAPElement addCDATA(String text) throws SOAPException {
   476         org.w3c.dom.Text cdata =
   670         org.w3c.dom.Text cdata =
   477             (org.w3c.dom.Text) getOwnerDocument().createCDATASection(text);
   671                 getOwnerDocument().createCDATASection(text);
   478         addNode(cdata);
   672         addNode(cdata);
   479         return this;
   673         return this;
   480     }
   674     }
   481 
   675 
   482     protected SOAPElement addText(String text) throws SOAPException {
   676     protected SOAPElement addText(String text) throws SOAPException {
   483         org.w3c.dom.Text textNode =
   677         org.w3c.dom.Text textNode =
   484             (org.w3c.dom.Text) getOwnerDocument().createTextNode(text);
   678                 getOwnerDocument().createTextNode(text);
   485         addNode(textNode);
   679         addNode(textNode);
   486         return this;
   680         return this;
   487     }
   681     }
   488 
   682 
   489     public SOAPElement addAttribute(Name name, String value)
   683     public SOAPElement addAttribute(Name name, String value)
   682     public Iterator<Node> getChildElements() {
   876     public Iterator<Node> getChildElements() {
   683         return getChildElementsFrom(this);
   877         return getChildElementsFrom(this);
   684     }
   878     }
   685 
   879 
   686     protected SOAPElement convertToSoapElement(Element element) {
   880     protected SOAPElement convertToSoapElement(Element element) {
   687         if (element instanceof SOAPElement) {
   881         final Node soapNode = getSoapDocument().findIfPresent(element);
   688             return (SOAPElement) element;
   882         if (soapNode instanceof SOAPElement) {
       
   883             return (SOAPElement) soapNode;
   689         } else {
   884         } else {
   690             return replaceElementWithSOAPElement(
   885             return replaceElementWithSOAPElement(
   691                 element,
   886                 element,
   692                 (ElementImpl) createElement(NameImpl.copyElementName(element)));
   887                 (ElementImpl) createElement(NameImpl.copyElementName(element)));
   693         }
   888         }
   694     }
   889     }
   695 
   890 
   696     protected static SOAPElement replaceElementWithSOAPElement(
   891     protected SOAPElement replaceElementWithSOAPElement(
   697         Element element,
   892         Element element,
   698         ElementImpl copy) {
   893         ElementImpl copy) {
   699 
   894 
   700         Iterator<Name> eachAttribute = getAllAttributesFrom(element);
   895         Iterator<Name> eachAttribute = getAllAttributesFrom(element);
   701         while (eachAttribute.hasNext()) {
   896         while (eachAttribute.hasNext()) {
   707         while (eachChild.hasNext()) {
   902         while (eachChild.hasNext()) {
   708             Node nextChild = eachChild.next();
   903             Node nextChild = eachChild.next();
   709             copy.insertBefore(nextChild, null);
   904             copy.insertBefore(nextChild, null);
   710         }
   905         }
   711 
   906 
   712         Node parent = element.getParentNode();
   907         Node parent = getSoapDocument().find(element.getParentNode());
   713         if (parent != null) {
   908         if (parent != null) {
   714             parent.replaceChild(copy, element);
   909             parent.replaceChild(copy, element);
   715         } // XXX else throw an exception?
   910         } // XXX else throw an exception?
   716 
   911 
   717         return copy;
   912         return copy;
   725 
   920 
   726             public boolean hasNext() {
   921             public boolean hasNext() {
   727                 if (next == null) {
   922                 if (next == null) {
   728                     while (eachNode.hasNext()) {
   923                     while (eachNode.hasNext()) {
   729                         Node node = eachNode.next();
   924                         Node node = eachNode.next();
   730                         if (node instanceof SOAPElement) {
   925                         if (node instanceof Element) {
   731                             next = node;
   926                             next = getSoapDocument().findIfPresent(node);
   732                             break;
   927                             break;
   733                         }
   928                         }
   734                     }
   929                     }
   735                 }
   930                 }
   736                 return next != null;
   931                 return next != null;
   897     }
  1092     }
   898 
  1093 
   899     protected javax.xml.soap.Node getValueNode() {
  1094     protected javax.xml.soap.Node getValueNode() {
   900         Iterator<Node> i = getChildElements();
  1095         Iterator<Node> i = getChildElements();
   901         while (i.hasNext()) {
  1096         while (i.hasNext()) {
   902             javax.xml.soap.Node n = (javax.xml.soap.Node) i.next();
  1097             Node n = i.next();
   903             if (n.getNodeType() == org.w3c.dom.Node.TEXT_NODE ||
  1098             if (n.getNodeType() == org.w3c.dom.Node.TEXT_NODE ||
   904                 n.getNodeType() == org.w3c.dom.Node.CDATA_SECTION_NODE) {
  1099                 n.getNodeType() == org.w3c.dom.Node.CDATA_SECTION_NODE) {
   905                 // TODO: Hack to fix text node split into multiple lines.
  1100                 // TODO: Hack to fix text node split into multiple lines.
   906                 normalize();
  1101                 normalize();
   907                 // Should remove the normalization step when this gets fixed in
  1102                 // Should remove the normalization step when this gets fixed in
   908                 // DOM/Xerces.
  1103                 // DOM/Xerces.
   909                 return (javax.xml.soap.Node) n;
  1104                 return getSoapDocument().find(n);
   910             }
  1105             }
   911         }
  1106         }
   912         return null;
  1107         return null;
   913     }
  1108     }
   914 
  1109 
   946     public SOAPElement getParentElement() {
  1141     public SOAPElement getParentElement() {
   947         Node parentNode = getParentNode();
  1142         Node parentNode = getParentNode();
   948         if (parentNode instanceof SOAPDocument) {
  1143         if (parentNode instanceof SOAPDocument) {
   949             return null;
  1144             return null;
   950         }
  1145         }
   951         return (SOAPElement) parentNode;
  1146         return (SOAPElement) getSoapDocument().find(parentNode);
   952     }
  1147     }
   953 
  1148 
   954     protected String getSOAPNamespace() {
  1149     protected String getSOAPNamespace() {
   955         String soapNamespace = null;
  1150         String soapNamespace = null;
   956 
  1151 
   973     }
  1168     }
   974 
  1169 
   975     public void detachNode() {
  1170     public void detachNode() {
   976         Node parent = getParentNode();
  1171         Node parent = getParentNode();
   977         if (parent != null) {
  1172         if (parent != null) {
   978             parent.removeChild(this);
  1173             parent.removeChild(element);
   979         }
  1174         }
   980         encodingStyleAttribute.clearNameAndValue();
  1175         encodingStyleAttribute.clearNameAndValue();
   981         // Fix for CR: 6474641
  1176         // Fix for CR: 6474641
   982         //tryToFindEncodingStyleAttributeName();
  1177         //tryToFindEncodingStyleAttributeName();
   983     }
  1178     }
  1134         attribute = element.getAttributeNode(qualifiedName);
  1329         attribute = element.getAttributeNode(qualifiedName);
  1135 
  1330 
  1136         return attribute == null ? null : attribute.getValue();
  1331         return attribute == null ? null : attribute.getValue();
  1137     }
  1332     }
  1138 
  1333 
  1139     protected static Iterator<Node> getChildElementsFrom(final Element element) {
  1334     protected Iterator<Node> getChildElementsFrom(final Element element) {
  1140         return new Iterator<Node>() {
  1335         return new Iterator<Node>() {
  1141             Node next = element.getFirstChild();
  1336             Node next = element.getFirstChild();
  1142             Node nextNext = null;
  1337             Node nextNext = null;
  1143             Node last = null;
  1338             Node last = null;
       
  1339             Node soapElement = getSoapDocument().findIfPresent(element);
  1144 
  1340 
  1145             public boolean hasNext() {
  1341             public boolean hasNext() {
  1146                 if (next != null) {
  1342                 if (next != null) {
  1147                     return true;
  1343                     return true;
  1148                 }
  1344                 }
  1149                 if (next == null && nextNext != null) {
  1345                 if (nextNext != null) {
  1150                     next = nextNext;
  1346                     next = nextNext;
  1151                 }
  1347                 }
  1152 
  1348 
  1153                 return next != null;
  1349                 return next != null;
  1154             }
  1350             }
  1156             public Node next() {
  1352             public Node next() {
  1157                 if (hasNext()) {
  1353                 if (hasNext()) {
  1158                     last = next;
  1354                     last = next;
  1159                     next = null;
  1355                     next = null;
  1160 
  1356 
  1161                     if ((element instanceof ElementImpl)
  1357                     if ((soapElement instanceof ElementImpl)
  1162                         && (last instanceof Element)) {
  1358                             && (last instanceof Element)) {
  1163                         last =
  1359                         last =
  1164                             ((ElementImpl) element).convertToSoapElement(
  1360                                 ((ElementImpl) soapElement).convertToSoapElement(
  1165                                 (Element) last);
  1361                                         (Element) last);
  1166                     }
  1362                     }
  1167 
  1363 
  1168                     nextNext = last.getNextSibling();
  1364                     nextNext = last.getNextSibling();
  1169                     return last;
  1365                     return getSoapDocument().findIfPresent(last);
  1170                 }
  1366                 }
  1171                 throw new NoSuchElementException();
  1367                 throw new NoSuchElementException();
  1172             }
  1368             }
  1173 
  1369 
  1174             public void remove() {
  1370             public void remove() {
  1249 //        if(elementQName.getLocalPart().equals("Fault") &&
  1445 //        if(elementQName.getLocalPart().equals("Fault") &&
  1250 //                (SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE.equals(value) ||
  1446 //                (SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE.equals(value) ||
  1251 //                SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE.equals(value)))
  1447 //                SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE.equals(value)))
  1252 //            return;
  1448 //            return;
  1253 
  1449 
  1254         super.setAttributeNS(namespaceURI,qualifiedName,value);
  1450         element.setAttributeNS(namespaceURI,qualifiedName,value);
  1255         //String tmpLocalName = this.getLocalName();
  1451         //String tmpLocalName = this.getLocalName();
  1256         String tmpURI = this.getNamespaceURI();
  1452         String tmpURI = this.getNamespaceURI();
  1257         boolean isIDNS = false;
  1453         boolean isIDNS = false;
  1258         if( tmpURI != null && (tmpURI.equals(DSIG_NS) || tmpURI.equals(XENC_NS))){
  1454         if( tmpURI != null && (tmpURI.equals(DSIG_NS) || tmpURI.equals(XENC_NS))){
  1259             isIDNS = true;
  1455             isIDNS = true;
  1268             }
  1464             }
  1269         }
  1465         }
  1270 
  1466 
  1271     }
  1467     }
  1272 
  1468 
       
  1469     @Override
       
  1470     public void removeAttributeNS(String namespaceURI, String localName) throws DOMException {
       
  1471         element.removeAttributeNS(namespaceURI, localName);
       
  1472     }
       
  1473 
       
  1474     @Override
       
  1475     public Attr getAttributeNodeNS(String namespaceURI, String localName) throws DOMException {
       
  1476         return element.getAttributeNodeNS(namespaceURI, localName);
       
  1477     }
       
  1478 
       
  1479     @Override
       
  1480     public Attr setAttributeNodeNS(Attr newAttr) throws DOMException {
       
  1481         return element.setAttributeNodeNS(newAttr);
       
  1482     }
       
  1483 
       
  1484     @Override
       
  1485     public NodeList getElementsByTagNameNS(String namespaceURI, String localName) throws DOMException {
       
  1486         return new NodeListImpl(getSoapDocument(), element.getElementsByTagNameNS(namespaceURI, localName));
       
  1487     }
       
  1488 
       
  1489     @Override
       
  1490     public boolean hasAttribute(String name) {
       
  1491         return element.hasAttribute(name);
       
  1492     }
       
  1493 
       
  1494     @Override
       
  1495     public boolean hasAttributeNS(String namespaceURI, String localName) throws DOMException {
       
  1496         return element.hasAttributeNS(namespaceURI, localName);
       
  1497     }
       
  1498 
       
  1499     @Override
       
  1500     public TypeInfo getSchemaTypeInfo() {
       
  1501         return element.getSchemaTypeInfo();
       
  1502     }
       
  1503 
       
  1504     @Override
       
  1505     public void setIdAttribute(String name, boolean isId) throws DOMException {
       
  1506         element.setIdAttribute(name, isId);
       
  1507     }
       
  1508 
       
  1509     @Override
       
  1510     public void setIdAttributeNS(String namespaceURI, String localName, boolean isId) throws DOMException {
       
  1511         element.setIdAttributeNS(namespaceURI, localName, isId);
       
  1512     }
       
  1513 
       
  1514     @Override
       
  1515     public void setIdAttributeNode(Attr idAttr, boolean isId) throws DOMException {
       
  1516         element.setIdAttributeNode(idAttr, isId);
       
  1517     }
       
  1518 
       
  1519     @Override
       
  1520     public String getNodeName() {
       
  1521         return element.getNodeName();
       
  1522     }
       
  1523 
       
  1524     @Override
       
  1525     public String getNodeValue() throws DOMException {
       
  1526         return element.getNodeValue();
       
  1527     }
       
  1528 
       
  1529     @Override
       
  1530     public void setNodeValue(String nodeValue) throws DOMException {
       
  1531         element.setNodeValue(nodeValue);
       
  1532     }
       
  1533 
       
  1534     @Override
       
  1535     public short getNodeType() {
       
  1536         return element.getNodeType();
       
  1537     }
       
  1538 
       
  1539     @Override
       
  1540     public Node getParentNode() {
       
  1541         return getSoapDocument().find(element.getParentNode());
       
  1542     }
       
  1543 
       
  1544     @Override
       
  1545     public NodeList getChildNodes() {
       
  1546         return new NodeListImpl(getSoapDocument(), element.getChildNodes());
       
  1547     }
       
  1548 
       
  1549     @Override
       
  1550     public Node getFirstChild() {
       
  1551         return getSoapDocument().findIfPresent(element.getFirstChild());
       
  1552     }
       
  1553 
       
  1554     @Override
       
  1555     public Node getLastChild() {
       
  1556         return getSoapDocument().findIfPresent(element.getLastChild());
       
  1557     }
       
  1558 
       
  1559     @Override
       
  1560     public Node getPreviousSibling() {
       
  1561         return getSoapDocument().findIfPresent(element.getPreviousSibling());
       
  1562     }
       
  1563 
       
  1564     @Override
       
  1565     public Node getNextSibling() {
       
  1566         return getSoapDocument().findIfPresent(element.getNextSibling());
       
  1567     }
       
  1568 
       
  1569     @Override
       
  1570     public NamedNodeMap getAttributes() {
       
  1571         return element.getAttributes();
       
  1572     }
       
  1573 
       
  1574     public Element getDomElement() {
       
  1575         return element;
       
  1576     }
       
  1577 
       
  1578     public SOAPDocumentImpl getSoapDocument() {
       
  1579         return soapDocument;
       
  1580     }
  1273 }
  1581 }