Hi! Is there a way to get JAXB to include default values for elements? That
is, given the schema:
<!-- Imprint group -->
<xs:element name="Imprint">
<xs:complexType>
<xs:sequence>
<xs:element ref="Imprint_date"/>
<xs:element ref="Imprint_volume" minOccurs="0"/>
<xs:element ref="Imprint_issue" minOccurs="0"/>
<xs:element ref="Imprint_pages" minOccurs="0"/>
<xs:element ref="Imprint_section" minOccurs="0"/>
<xs:element ref="Imprint_language" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
...
<xs:element name="Imprint_language" type="xs:string" default="ENG"/>
JAXB allows the above syntax, but doesn't use the default "ENG" string
anywhere in the generated .java code. I would like to see the method
ImprintTypeImpl.getImprint_language() return "ENG" if a value has not
explicitly been set, perhaps by simply setting a default value in the class
code, e.g.:
public class ImprintTypeImpl implements ncbi.pubchem.ImprintType, com.sun.xml.bind.JAXBObject, ncbi.pubchem.impl.runtime.UnmarshallableObject, ncbi.pubchem.impl.runtime.XMLSerializable, ncbi.pubchem.impl.runtime.ValidatableObject
{
...
protected java.lang.String _Imprint_language = "ENG";
Would something like this be possible? Or maybe there's some other way to
specify a default value in the schema? I know defaults can be set up for
attributes, but is there a way to set a default for an actual (simple type)
element value?
- Paul
--
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Paul A. | NCBI / NIH
Thiessen | thiessen_at_ncbi.nlm.nih.gov
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+