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