users@jaxb.java.net

Fixed Value in a schema

From: Jamie Johnson <jej2003_at_gmail.com>
Date: Wed, 27 Apr 2011 16:14:04 -0400

I have a schema with an attribute with a fixed value. JAXB generates
the following given the schema:

 @XmlAttribute(name = "version")
    protected String version;
    public String getVersion() {
        if (version == null) {
            return "2.0";
        } else {
            return version;
        }
    }

but since the XmlAccessType on the class is set to XmlAccessType.FIELD
the version value is null. Is there a way when generating the class
through an external binding to instead generate a class that looks
like this:

 @XmlAttribute(name = "version")
    protected String version = "2.0";
    public String getVersion() {
            return version;
    }