Sylvain Wallez wrote:
Mmmh... (again!), thinking further, maybe accepting an empty input value should be part of the Convertor contract (which is not the case today): we could then have the boolean convertor return false when the value is null or equals "false", and all other convertors (int, float, string, etc) generally return null when the value is null also. In that case, booleanfield can be removed.
This will not work: <field/> of boolean type has three values: null, true, false; changing the behavior of convertor to treat null as false will break this. To give you an example when this is necessary:
<xs:element name="some-boolean" type="xs:boolean" minOccurs="0" />
Here, you have to differentiate between null and false. I agree that checkbox does not has third value - so in case of checkbox null will mean false. But in case of radio buttons (Yes/No/Don't know), or selection lists, third value can be easily preserved.
Actually, we encounter here the distinction that exists between "boolean" (the java primitive type) which can be true/false and nothing else, and "java.lang.Boolean" which can be Boolean.TRUE, Boolean.FALSE and null (i.e. "don't know").
We can easily achieve this distinction with either different convertors or different datatypes, or even a default value.
WDYT?
Sylvain
-- Sylvain Wallez Anyware Technologies http://www.apache.org/~sylvain http://www.anyware-tech.com { XML, Java, Cocoon, OpenSource }*{ Training, Consulting, Projects } Orixo, the opensource XML business alliance - http://www.orixo.com
