This content has been marked as final.
Show 4 replies
-
1. Re: @XmlElement(defaultValue=
aloubyansky Oct 16, 2007 8:41 AM (in response to starksm64)But the element must still be present in the XML.
"jaxb20 spec" wrote:
Element defaulting
The default value is derived from the element declaration?s {value
constraint} property?s value. Unlike attribute defaulting, an element only
defaults when there is an empty element tag in an xml document. The
element?s default value is captured by mapping annotation
@XmlElement.defaultValue(). The unmarshaller sets the
property to this default value when it encounters an empty element tag. -
2. Re: @XmlElement(defaultValue=
jason.greene Oct 16, 2007 10:59 AM (in response to starksm64)The following link explains this further, it basically mirrors XML schema default behavior:
https://jaxb.dev.java.net/guide/Element_default_valus_and_unmarshalling.html -
3. Re: @XmlElement(defaultValue=
starksm64 Oct 16, 2007 2:13 PM (in response to starksm64)Ok, so I assme that the xjc tool would not generate a class with the field initialized to this default value then as it would distinguish between a non-existent value and a default?
-
4. Re: @XmlElement(defaultValue=
jason.greene Oct 16, 2007 5:18 PM (in response to starksm64)Exactly. xjc uses the defaultValue attribute instead.