Skip to main content

XmlAttribute not influenced by the 'required' setting

1 reply [Last post]
amarkel
Offline
Joined: 2004-05-13

I just refreshed my view of JAXB 2.0 (thinking that
it would fix the problem reported).

package foo;

import javax.xml.bind.annotation.AccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;

@XmlAccessorType(AccessType.PROPERTY)
@XmlType( name = "record" )
public class Record {

protected boolean table;
public Record() {}
public Record( boolean tab ) {
setTable( tab );
}

@XmlAttribute( name = "table" )
public boolean isTable() { return table; }
public void setTable( boolean tab ) {
table = tab;
}
}

The documentation states that the default should be
false.

Even when I explicitly set required to 'false', the
xsd still said 'required = true'.

Ideas ?

Thanks,

Arieh

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
kohsuke
Offline
Joined: 2003-06-09

It's a primitive type, so that's why it's always required, although it seems to me that you are right that something is wrong (or at least not well described.)

Try changing it to Boolean the wrapper type.