[prev in list] [next in list] [prev in thread] [next in thread] 

List:       woden-dev
Subject:    Re: Axiom looses information when a child element is re-added to its parent using #addChild
From:       Kasun Gajasinghe <kasunbg () gmail ! com>
Date:       2012-02-28 0:50:33
Message-ID: CADg9GQZkLFRJxGi4ynVQZOcxPf=OnyEjwQ9LZO1GZyXMJqvEvA () mail ! gmail ! com
[Download RAW message or body]

On Tue, Feb 28, 2012 at 2:14 AM, Andreas Veithen
<andreas.veithen@gmail.com>wrote:

> Should be fixed now (see AXIOM-411). Thanks for reporting this issue.
>

Great. Glad to be of help!

--Kasun


>
> Andreas
>
> On Thu, Feb 23, 2012 at 15:26, Kasun Gajasinghe <kasunbg@gmail.com> wrote:
> > Hi,
> >
> > I've using Axiom for some work, and I've faced this issue that I think
> is a
> > bug in Axiom. The issue occurs when a given OMElement is re-added to its
> > parent using parentOMElement#addChild method. In that case, the said
> parent
> > loses references to all the children after the child OMElement.
> >
> > To make it clear consider the sample xml doc [1]. Now, say you retrieved
> the
> > operation named "Sandesha2OperationInOnly", by xpath or any other means.
> > Then, you re add it to the parent <service>. After that, service loose
> > references to siblings after the said retrieved element (ie. <binding>
> and
> > <parameter>). I've provided a sample code for this which I've simplified
> to
> > not use xpath for better understanding. [2]
> >
> > Yes, I can do a validation on whether I'm adding a child to the same
> parent,
> > but why? This should be handled at Axiom level. The example was a much
> > simplified version; I've spent hours wondering how I lost all those
> > information, and found that a seemingly innocent method invocation was
> the
> > cause! :) Can anyone reproduce this? I'd like to provide a patch for
> this.
> >
> > [1]
> > <service name="HelloService">
> >     <operation name="Sandesha2OperationOutIn"/>
> >     <operation name="Sandesha2OperationInOnly"/>
> >     <binding name="HelloServiceSoap12Binding">
> >         <operation name="greet"/>
> >     </binding>
> >     <parameter name="name1">val1</parameter>
> > </service>
> >
> > [2]
> > OMElement documentEle = new
> > StAXOMBuilder("resources/services-op-test.xml").getDocumentElement();
> >
> > // Now retrieve <operation name="Sandesha2OperationInOnly" />
> > OMElement opElement2 = (OMElement)
> > documentEle.getFirstElement().getNextOMSibling().getNextOMSibling();
> > //OMElement opElement2 = new
> >
> AXIOMXPath("/service/operation[@name=\"Sandesha2OperationInOnly\"]").selectSingleNode(documentEle);
> >
> > documentEle.addChild(opElement2);
> >
> >
> > --
> > ~~~*******'''''''''''''*******~~~
> > Kasun Gajasinghe
> > Software Engineer; WSO2 Inc.; http://wso2.com,
> > linked-in: http://lk.linkedin.com/in/gajasinghe
> > blog: http://blog.kasunbg.org
> >
> >
> > twitter: http://twitter.com/kasunbg
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: dev-help@ws.apache.org
>
>


-- 
~~~*******'''''''''''''*******~~~
*Kasun Gajasinghe*
Software Engineer; WSO2 Inc.; http://wso2.com,
*linked-in: *http://lk.linkedin.com/in/gajasinghe*
*
*blog: **http://blog.kasunbg.org* <http://blog.kasunbg.org/>

*
twitter: **http://twitter.com/kasunbg* <http://twitter.com/kasunbg>

[Attachment #3 (text/html)]

<br><br><div class="gmail_quote">On Tue, Feb 28, 2012 at 2:14 AM, Andreas Veithen \
<span dir="ltr">&lt;<a \
href="mailto:andreas.veithen@gmail.com">andreas.veithen@gmail.com</a>&gt;</span> \
wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px \
#ccc solid;padding-left:1ex">

Should be fixed now (see AXIOM-411). Thanks for reporting this \
issue.<br></blockquote><div><br></div><div>Great. Glad to be of help!  \
</div><div><br></div><div>--Kasun</div><div>  </div><blockquote class="gmail_quote" \
style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


<br>
Andreas<br>
<div><div class="h5"><br>
On Thu, Feb 23, 2012 at 15:26, Kasun Gajasinghe &lt;<a \
href="mailto:kasunbg@gmail.com">kasunbg@gmail.com</a>&gt; wrote:<br> &gt; Hi,<br>
&gt;<br>
&gt; I&#39;ve using Axiom for some work, and I&#39;ve faced this issue that I think \
is a<br> &gt; bug in Axiom. The issue occurs when a given OMElement is re-added to \
its<br> &gt; parent using parentOMElement#addChild method. In that case, the said \
parent<br> &gt; loses references to all the children after the child OMElement.<br>
&gt;<br>
&gt; To make it clear consider the sample xml doc [1]. Now, say you retrieved the<br>
&gt; operation named &quot;Sandesha2OperationInOnly&quot;, by xpath or any other \
means.<br> &gt; Then, you re add it to the parent &lt;service&gt;. After that, \
service loose<br> &gt; references to siblings after the said retrieved element (ie. \
&lt;binding&gt; and<br> &gt; &lt;parameter&gt;). I&#39;ve provided a sample code for \
this which I&#39;ve simplified to<br> &gt; not use xpath for better understanding. \
[2]<br> &gt;<br>
&gt; Yes, I can do a validation on whether I&#39;m adding a child to the same \
parent,<br> &gt; but why? This should be handled at Axiom level. The example was a \
much<br> &gt; simplified version; I&#39;ve spent hours wondering how I lost all \
those<br> &gt; information, and found that a seemingly innocent method invocation was \
the<br> &gt; cause! :) Can anyone reproduce this? I&#39;d like to provide a patch for \
this.<br> &gt;<br>
&gt; [1]<br>
&gt; &lt;service name=&quot;HelloService&quot;&gt;<br>
&gt;       &lt;operation name=&quot;Sandesha2OperationOutIn&quot;/&gt;<br>
&gt;       &lt;operation name=&quot;Sandesha2OperationInOnly&quot;/&gt;<br>
&gt;       &lt;binding name=&quot;HelloServiceSoap12Binding&quot;&gt;<br>
&gt;             &lt;operation name=&quot;greet&quot;/&gt;<br>
&gt;       &lt;/binding&gt;<br>
&gt;       &lt;parameter name=&quot;name1&quot;&gt;val1&lt;/parameter&gt;<br>
&gt; &lt;/service&gt;<br>
&gt;<br>
&gt; [2]<br>
&gt; OMElement documentEle = new<br>
&gt; StAXOMBuilder(&quot;resources/services-op-test.xml&quot;).getDocumentElement();<br>
 &gt;<br>
&gt; // Now retrieve  &lt;operation name=&quot;Sandesha2OperationInOnly&quot; \
/&gt;<br> &gt; OMElement opElement2 = (OMElement)<br>
&gt; documentEle.getFirstElement().getNextOMSibling().getNextOMSibling();<br>
&gt; //OMElement opElement2 = new<br>
&gt; AXIOMXPath(&quot;/service/operation[@name=\&quot;Sandesha2OperationInOnly\&quot;]&quot;).selectSingleNode(documentEle);<br>
 &gt;<br>
&gt; documentEle.addChild(opElement2);<br>
&gt;<br>
&gt;<br>
&gt; --<br>
&gt; ~~~*******&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;*******~~~<br>
 &gt; Kasun Gajasinghe<br>
&gt; Software Engineer; WSO2 Inc.;  <a href="http://wso2.com" \
target="_blank">http://wso2.com</a>,<br> &gt; linked-in:  <a \
href="http://lk.linkedin.com/in/gajasinghe" \
target="_blank">http://lk.linkedin.com/in/gajasinghe</a><br> &gt; blog:  <a \
href="http://blog.kasunbg.org" target="_blank">http://blog.kasunbg.org</a><br> \
&gt;<br> &gt;<br>
&gt; twitter:  <a href="http://twitter.com/kasunbg" \
target="_blank">http://twitter.com/kasunbg</a><br> &gt;<br>
<br>
</div></div>---------------------------------------------------------------------<br>
To unsubscribe, e-mail: <a \
href="mailto:dev-unsubscribe@ws.apache.org">dev-unsubscribe@ws.apache.org</a><br> For \
additional commands, e-mail: <a \
href="mailto:dev-help@ws.apache.org">dev-help@ws.apache.org</a><br> <br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><font \
size="1">~~~*******&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;*******~~~<br></font><b>Kasun \
Gajasinghe</b><br><font size="1">Software Engineer; WSO2 Inc.;</font>  <span \
style="font-size:x-small"><a href="http://wso2.com/" \
target="_blank">http://wso2.com</a>,</span><span style="font-size:x-small"><br>

</span><div><i><span style="font-size:x-small">linked-in:  </span></i><a \
href="http://lk.linkedin.com/in/gajasinghe" target="_blank"><font \
size="1">http://lk.linkedin.com/in/gajasinghe</font></a><font \
size="1"><i><br></i></font><div>

<div><i><span style="font-size:x-small">blog:  </span></i><a \
href="http://blog.kasunbg.org/" target="_blank"><i><span \
style="font-size:x-small">http://blog.kasunbg.org</span></i></a><div \
style="background-color:initial;margin-left:4px;padding-bottom:2px;display:inline-block;width:16px;height:16px">


  </div><i><span style="font-size:x-small"><br>twitter:  </span></i><a \
href="http://twitter.com/kasunbg" target="_blank"><i><span \
style="font-size:x-small">http://twitter.com/kasunbg</span></i></a></div></div></div><br>




[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic