You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by zulu <su...@hotmail.com> on 2007/10/03 02:21:06 UTC

how to find out if child elements are empty

Hi All,

We are currently working on a huge xml payload (constructing as well as
consuming xml) through XMLBeans. 
In this case we are constructing a payload.
The scenario we are encountering problem is say we have a parent element
this does not have a value but comprises of other child elements. 
Now the application is such that the population of the child elements is
different routine and many conditions have to be met before the child
elements of this parent get populated.
Whereas the parent element gets created early on. So in a few scenarios the
child elements will not be populated but the parent node has already got
created. In such cases we want to remove the parent node. 

We want to have a check to see if none of the child elements of this parent
are set then unset the parent element. Is there a way to achieve the same.
Do post your thoughts.


-- 
View this message in context: http://www.nabble.com/how-to-find-out-if-child-elements-are-empty-tf4559150.html#a13010839
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: how to find out if child elements are empty

Posted by Radu Preotiuc-Pietro <ra...@bea.com>.
That's hardly helpful...

Assuming that "xmlobj" is your parent object (that you want to check),
then simply do

boolean empty = xmlobj.newCursor().toNextToken().isEnd();

Radu

On Tue, 2007-10-02 at 18:29 -0700, jimmy Zhang wrote:
> I think you should try VTD-XML for that
> http://vtd-xml.sf.net
> 
> ----- Original Message ----- 
> From: "zulu" <su...@hotmail.com>
> To: <us...@xmlbeans.apache.org>
> Sent: Tuesday, October 02, 2007 5:21 PM
> Subject: how to find out if child elements are empty
> 
> 
> >
> > Hi All,
> >
> > We are currently working on a huge xml payload (constructing as well as
> > consuming xml) through XMLBeans.
> > In this case we are constructing a payload.
> > The scenario we are encountering problem is say we have a parent element
> > this does not have a value but comprises of other child elements.
> > Now the application is such that the population of the child elements is
> > different routine and many conditions have to be met before the child
> > elements of this parent get populated.
> > Whereas the parent element gets created early on. So in a few scenarios 
> > the
> > child elements will not be populated but the parent node has already got
> > created. In such cases we want to remove the parent node.
> >
> > We want to have a check to see if none of the child elements of this 
> > parent
> > are set then unset the parent element. Is there a way to achieve the same.
> > Do post your thoughts.
> >
> >
> > -- 
> > View this message in context: 
> > http://www.nabble.com/how-to-find-out-if-child-elements-are-empty-tf4559150.html#a13010839
> > 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
> 

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: how to find out if child elements are empty

Posted by jimmy Zhang <jz...@ximpleware.com>.
I think you should try VTD-XML for that
http://vtd-xml.sf.net

----- Original Message ----- 
From: "zulu" <su...@hotmail.com>
To: <us...@xmlbeans.apache.org>
Sent: Tuesday, October 02, 2007 5:21 PM
Subject: how to find out if child elements are empty


>
> Hi All,
>
> We are currently working on a huge xml payload (constructing as well as
> consuming xml) through XMLBeans.
> In this case we are constructing a payload.
> The scenario we are encountering problem is say we have a parent element
> this does not have a value but comprises of other child elements.
> Now the application is such that the population of the child elements is
> different routine and many conditions have to be met before the child
> elements of this parent get populated.
> Whereas the parent element gets created early on. So in a few scenarios 
> the
> child elements will not be populated but the parent node has already got
> created. In such cases we want to remove the parent node.
>
> We want to have a check to see if none of the child elements of this 
> parent
> are set then unset the parent element. Is there a way to achieve the same.
> Do post your thoughts.
>
>
> -- 
> View this message in context: 
> http://www.nabble.com/how-to-find-out-if-child-elements-are-empty-tf4559150.html#a13010839
> 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