Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] Node empty or not.

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: "Jason C. Leach" <jleach AT ocis.net>
  • To: John Cowan <jcowan AT reutershealth.com>
  • Cc: xom-interest AT lists.ibiblio.org
  • Subject: Re: [XOM-interest] Node empty or not.
  • Date: Thu, 19 Jun 2003 09:38:38 -0700


hi,

I don't think that does what I expect. For example, in the XML node:
...
<mustHave>
<cn>jason</cn>
<gidNumber/>
</mustHave>
...

The cn tag has some content, the gidNumber is empty. I would
like to be able to destinguis between a child with content (cn)
and without (gidNumber). I know I can do this by opening the
up, doing a getValue and seeing if anything exists, but that
does not seem like a very good method.

The getChildCount() does not seem to work the way I expect either.
For example, in the XML:
<?xml version="1.0" encoding="ISO-8859-1"?>
<objectClass type="posixGroup">
<mustHave quantity="2">
<cn>oop</cn>
<gidNumber/>
</mustHave>
<mayHave quantity="3">
<userPassword/>
<memberUid/>
<description/>
</mayHave>
</objectClass>

System.out.println(doc.getRootElement().getFirstChildElement("mustHave").getChildCount());

Returns 5. Where doc is the XML document. I'm not sure why I get 5 back.
I would think I should get 2 or 3 (if for some reason it included the
attribute); or better yet 1 which is exactly what I want.

Thanks,
j.



On Wed, Jun 18, 2003 at 02:45:35PM -0400, John Cowan wrote:
> Jason C. Leach scripsit:
>
> > Is there a quick way to determine if a node is empty or not, like:
> >
> > empty node is <cn/>
> >
> > not empty is <cn>jason</cn>
>
> anElement.getChildCount() == 0 means empty.
>
> --
> They do not preach John Cowan
> that their God will rouse them jcowan AT reutershealth.com
> A little before the nuts work loose. http://www.ccil.org/~cowan
> They do not teach http://www.reutershealth.com
> that His Pity allows them --Rudyard Kipling,
> to drop their job when they damn-well choose. "The Sons of Martha"
>

--
......................
..... Jason C. Leach
..

Current PGP/GPG Key ID: 43AD2024



On Wed, Jun 18, 2003 at 02:45:35PM -0400, John Cowan wrote:
> Jason C. Leach scripsit:
>
> > Is there a quick way to determine if a node is empty or not, like:
> >
> > empty node is <cn/>
> >
> > not empty is <cn>jason</cn>
>
> anElement.getChildCount() == 0 means empty.
>
> --
> They do not preach John Cowan
> that their God will rouse them jcowan AT reutershealth.com
> A little before the nuts work loose. http://www.ccil.org/~cowan
> They do not teach http://www.reutershealth.com
> that His Pity allows them --Rudyard Kipling,
> to drop their job when they damn-well choose. "The Sons of Martha"
>

--
......................
..... Jason C. Leach
..

Current PGP/GPG Key ID: 43AD2024




Archive powered by MHonArc 2.6.24.

Top of Page