When you don't set it to null, it doesn't generate the element.
The attribute is not marked required.
Here's a more detailed example:
This XSD: <xsd:attribute name="IdentificationNumber" type="xsd:string" />
This code: whateverElement.setIdentificationNumber( null );
Generates this XML: <whateverElement IdentificationNumber="" />
And if you don't set it to null, and do nothing, it generates this XML <whateverElement />
The reason that I'd like to get nulls to not generate the attribute is that my domain class returns null for values and I'd prefer to be able to send in null and not get an attribute generated. Otherwise I'd have to wrap each setter method in a null check.
-peter
| "Jacob Danner"
<[EMAIL PROTECTED]>
09/06/2005 06:10 PM
|
|
What happens when you don’t set the value to null?
Also you may what to check out the schema for the element to see if the value is required,
From: Peter Luttrell [mailto:[EMAIL PROTECTED]
Sent: Tuesday, September 06, 2005 9:08 AM
To: [email protected]
Subject: Nulls?
Is there any way to get xmlbeans go not generate an elements' attribute when it's field value is set to null?
For example, if I execute the following code:
whateverElement.setWhateverField( null );
xmlbeans generates this xml attribute:
WhateverField=""
I'd much rather have it generate nothing.
-peter --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

