xml-xmlbeans-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Coburn Kimberley <Kimberley.Cob...@softlab.de>
Subject Testing for empty elements
Date Fri, 23 Jul 2004 18:11:25 GMT

I am looking for a good way to test whether an element is empty. For example, I have a Customer
type that has a Vehicle type as child.

For an instance:


I want to be able to either ask the Customer if its Vehicle is empty or ask the Vehicle directly
if it is empty.

I thought I could do this with isNil() and isFooNil(). Anyhow, that's how I interpreted the
Bea XMLBean documentation on these methods. I've found out via experimentation that this is
not so - i.e. isNil()/isFooNil() only look at the xsi:nil attribute to see if it is true or
false; if the attribute is missing (in my case, yes), false is always returned. (I set the
nillable attribute in the schema, but this seems to only mean that I then get methods which
I can use to explicitly set the xsi:nil attribute).

In any case, all I want to do is ask if the element is empty - not if an attribute has a certain
value. At present, I am using the very ugly workaround of testing for Element.toString().equals("<xml-fragment/>")
or Element.toString().equals("<xml-fragement></xml-fragment>").
There must be a better way. Does anyone know one?


Kimberley Coburn

- ---------------------------------------------------------------------
To unsubscribe, e-mail:   xmlbeans-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-user-help@xml.apache.org
Apache XMLBeans Project -- URL: http://xml.apache.org/xmlbeans/

View raw message