On second thoughts, interface javax.xml.soap.Node extends org.w3c.dom.Node, hence I agree that wherever we return org.w3c.dom.Node, we should return javax.xml.soap.Node & not org.apache.axis2.om.impl.dom.NodeImpl, in order to be spec compliant.
Regards Azeez On 2/14/06, Afkham Azeez <[EMAIL PROTECTED]> wrote: > > > > Consider the following code from the SOAPElementTest: > > > > final String value = "foo"; > > soapElem.addTextNode(value); > > > > I should be able to get the javax.xml.soap.Node using several > > different accessors (getChildElements(), getChildNodes(), > > getFirstChild()), etc. > > > > ------------------------------ > > Problem 1: > > Object x = soapElem.getChildElements().next(); > > Object y = soapElem.getChildElements().next(); > > > > In this case, x and y are both javax.xml.soap.Node objects (good); > > however they are not the same object. The iterator is constructing > > new objects each time it is invoked. This is not efficient and > > incorrect. > > I agree with Ias on this point. Only if you call > soapElem.getChildElements(), new objects will be created. > > > > > ------------------------------- > > Problem 2 > > Object z1 = soapElem.getChildNodes().item(0); > > Object z2 = soapElem.getFirstChild(); > > > > In both cases, the returned object is not an SAAJ > > javax.xml.soap.Node. This also seems to be a violation of the > > specification. > Note that the javax.xml.SOAPElement extends org.w3c.dom.Node. The > getChildNodes() and getFirstChild() methods are inherited from the > org.w3c.dom.Node interface. Hence we cannot return javax.xml.soap.Node > objects from these methods. For instance, the method signature of > getFirstChild() is; > public org.w3c.dom.Node getFirstChild(); > So now we can see that, we cannot return javax.xml.soap.Node objects. > In order to use only SAAJ interfaces, you need to use the methods that > are directly in the javax.xml.SOAPElement interface. > > Regards > Azeez > -- Thanks Afkham Azeez
