You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by janbanan <ba...@gmail.com> on 2007/12/20 15:31:22 UTC

Remove node from "dot-syntax"

Hi,

I trying to work with an xmlbean from a "dot-syntax" property (lacking a
better word..).

What I have to go on is a string "person.address.zip" and an xmlbean Person
corresponding to the xml below.
What I want to do is delete the "person.address.zip" element from the bean.
With beanutils I can easily get the value and change the value to null.
However the element would still be there, just empty...

is this completely undoable? feel that way :(
any input appreciated!
thanks

<person>
 <address>
   <name>asdasd</name>
   <street>main street</street>
   <zip>12345</zip>                  <-- want to remove this completely...
</address>
</person>

-- 
View this message in context: http://www.nabble.com/Remove-node-from-%22dot-syntax%22-tp14437537p14437537.html
Sent from the Xml Beans - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org


RE: Remove node from "dot-syntax"

Posted by Radu Preotiuc-Pietro <ra...@bea.com>.
FWIW, this is how I would approach the problem:

1. Turn the "dot-syntax" expression into an Xpath. If your Schema
doesn't have a target namespace, then this is trivial: replace the "."s
with "/"s. If it does, then it's a bit more complicated, because you
need to do something with localName(), I don't know Xpath well enough;

2. use XmlObject.selectPath() to find the node that you want to delete;

3. use XmlObject.newCursor().removeXml() to eliminate the node.

Hope this helps,
Radu

> -----Original Message-----
> From: janbanan [mailto:bastavalla@gmail.com] 
> Sent: Thursday, December 20, 2007 10:56 AM
> To: user@xmlbeans.apache.org
> Subject: Re: Remove node from "dot-syntax"
> 
> 
> Hi,
> 
> It has minoccurences to 0 so it should be "deleteable".
> I just dont know how to navigate to the node och remove it 
> given only the "person.address.zip"-string...
> possible some sort of xquery?
> 
> 
> 
> Jacob Danner-2 wrote:
> > 
> > How is the type defined in your xsd? You may want to check your 
> > minOccurs or nillable attributes on teh xsd
> > 
> > On Dec 20, 2007 6:31 AM, janbanan <ba...@gmail.com> wrote:
> >>
> >> Hi,
> >>
> >> I trying to work with an xmlbean from a "dot-syntax" property 
> >> (lacking a better word..).
> >>
> >> What I have to go on is a string "person.address.zip" and 
> an xmlbean 
> >> Person corresponding to the xml below.
> >> What I want to do is delete the "person.address.zip" 
> element from the 
> >> bean.
> >> With beanutils I can easily get the value and change the 
> value to null.
> >> However the element would still be there, just empty...
> >>
> >> is this completely undoable? feel that way :( any input 
> appreciated!
> >> thanks
> >>
> >> <person>
> >>  <address>
> >>    <name>asdasd</name>
> >>    <street>main street</street>
> >>    <zip>12345</zip>                  <-- want to remove this
> >> completely...
> >> </address>
> >> </person>
> >>
> >> --
> >> View this message in context:
> >> 
> http://www.nabble.com/Remove-node-from-%22dot-syntax%22-tp14437537p14
> >> 437537.html Sent from the Xml Beans - User mailing list archive at 
> >> Nabble.com.
> >>
> >>
> >> 
> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> >> For additional commands, e-mail: user-help@xmlbeans.apache.org
> >>
> >>
> > 
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> > For additional commands, e-mail: user-help@xmlbeans.apache.org
> > 
> > 
> > 
> 
> --
> View this message in context: 
> http://www.nabble.com/Remove-node-from-%22dot-syntax%22-tp1443
> 7537p14442647.html
> Sent from the Xml Beans - User mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> For additional commands, e-mail: user-help@xmlbeans.apache.org
> 
> 

Notice:  This email message, together with any attachments, may contain information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated entities,  that may be confidential,  proprietary,  copyrighted  and/or legally privileged, and is intended solely for the use of the individual or entity named in this message. If you are not the intended recipient, and have received this message in error, please immediately return this by email and then delete it.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org


Re: Remove node from "dot-syntax"

Posted by janbanan <ba...@gmail.com>.
Hi,

It has minoccurences to 0 so it should be "deleteable".
I just dont know how to navigate to the node och remove it given only the
"person.address.zip"-string...
possible some sort of xquery?



Jacob Danner-2 wrote:
> 
> How is the type defined in your xsd? You may want to check your
> minOccurs or nillable attributes on teh xsd
> 
> On Dec 20, 2007 6:31 AM, janbanan <ba...@gmail.com> wrote:
>>
>> Hi,
>>
>> I trying to work with an xmlbean from a "dot-syntax" property (lacking a
>> better word..).
>>
>> What I have to go on is a string "person.address.zip" and an xmlbean
>> Person
>> corresponding to the xml below.
>> What I want to do is delete the "person.address.zip" element from the
>> bean.
>> With beanutils I can easily get the value and change the value to null.
>> However the element would still be there, just empty...
>>
>> is this completely undoable? feel that way :(
>> any input appreciated!
>> thanks
>>
>> <person>
>>  <address>
>>    <name>asdasd</name>
>>    <street>main street</street>
>>    <zip>12345</zip>                  <-- want to remove this
>> completely...
>> </address>
>> </person>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Remove-node-from-%22dot-syntax%22-tp14437537p14437537.html
>> Sent from the Xml Beans - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
>> For additional commands, e-mail: user-help@xmlbeans.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> For additional commands, e-mail: user-help@xmlbeans.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Remove-node-from-%22dot-syntax%22-tp14437537p14442647.html
Sent from the Xml Beans - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org


Re: Remove node from "dot-syntax"

Posted by Jacob Danner <ja...@gmail.com>.
How is the type defined in your xsd? You may want to check your
minOccurs or nillable attributes on teh xsd

On Dec 20, 2007 6:31 AM, janbanan <ba...@gmail.com> wrote:
>
> Hi,
>
> I trying to work with an xmlbean from a "dot-syntax" property (lacking a
> better word..).
>
> What I have to go on is a string "person.address.zip" and an xmlbean Person
> corresponding to the xml below.
> What I want to do is delete the "person.address.zip" element from the bean.
> With beanutils I can easily get the value and change the value to null.
> However the element would still be there, just empty...
>
> is this completely undoable? feel that way :(
> any input appreciated!
> thanks
>
> <person>
>  <address>
>    <name>asdasd</name>
>    <street>main street</street>
>    <zip>12345</zip>                  <-- want to remove this completely...
> </address>
> </person>
>
> --
> View this message in context: http://www.nabble.com/Remove-node-from-%22dot-syntax%22-tp14437537p14437537.html
> Sent from the Xml Beans - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> For additional commands, e-mail: user-help@xmlbeans.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org