After apply the patch, castor will raise following exceptions:
org.exolab.castor.xml.MarshalException: The following error occured
while trying to unmarshal field _booleanElement of class
test.gen.BuiltinTypes.{File: ; line: 6; column: 42}
at
org.exolab.castor.xml.Unmarshaller.convertSAXExceptionToMarshalException(Unmarshaller.java:794)
at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:760)
at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:626)
at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:840)
at test.gen.BuiltinTypes.unmarshalBuiltinTypes(BuiltinTypes.java:228)
at test.ValidationTest.main(ValidationTest.java:25)
......
Caused by: java.lang.IllegalArgumentException: A value of >whatever<
cannot be converted to a boolean value.
at
org.exolab.castor.xml.UnmarshalHandler.toPrimitiveObject(UnmarshalHandler.java:3766)
at
org.exolab.castor.xml.UnmarshalHandler.toPrimitiveObject(UnmarshalHandler.java:3707)
... 12 more
Thanks a lot for the help.
Andrew
On Thu, Apr 23, 2009 at 6:18 PM, Werner Guttmann <[email protected]> wrote:
> Hi,
>
> I just attached an initial patch. Are you in a position to checkout
> Castor from SVN trunk, apply the patch and build Castor binaries
> yourself ? And provide me with feedback ?
>
> Werner
>
> Andrew wrote:
>> Werner,
>>
>> I had submitted a ticket.
>>
>> http://jira.codehaus.org/browse/CASTOR-2699
>>
>> Thanks,
>> Andrew
>> On Thu, Apr 23, 2009 at 2:42 PM, Werner Guttmann <[email protected]>
>> wrote:
>>> Andrew,
>>>
>>> looks like you have indeed come across a problem with handling of
>>> 'boolean values'. Can I please ask you to raise a new Jira issue at
>>>
>>> http://jira.codehaus.org/browse/CASTOR
>>>
>>> and we'll be dealing with it through this ticket.
>>>
>>> Thanks
>>> Werner
>>>
>>> Andrew wrote:
>>>> I'm trying to use castor 1.3 as the validator of incoming xml
>>>> documents. This is a basic XML schema contains only built-in types:
>>>> <?xml version="1.0"?>
>>>> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
>>>> xmlns:basic="http://www.example.com/test"
>>>> targetNamespace="http://www.example.com/test">
>>>>
>>>> <xs:element name = "BuiltinElement" type="basic:BuiltinTypes"/>
>>>> <xs:complexType name="BuiltinTypes">
>>>> <xs:sequence>
>>>> <xs:element name="StringElement" type="xs:string" />
>>>> <xs:element name="IntegerElement" type="xs:integer"/>
>>>> <xs:element name="BooleanElement" type="xs:boolean"/>
>>>> </xs:sequence>
>>>> </xs:complexType>
>>>> </xs:schema>
>>>>
>>>> After generate java and descriptor classes, I try to validation some
>>>> xml instances in ValidateTest.java. Parser validation is disabled by
>>>> default. This is my validation related configurations in
>>>> castor.properties:
>>>> org.exolab.castor.parser.validation=false
>>>> org.exolab.castor.parser.namespaces=false
>>>> org.exolab.castor.marshalling.validation=true
>>>>
>>>> ValidateTest.java:
>>>> public static void main( String[] args ) {
>>>> String filename = args[0];
>>>> try {
>>>>
>>>> BuiltinTypes builtin01 =
>>>> BuiltinTypes.unmarshalBuiltinTypes(new
>>>> FileReader(filename));
>>>> StringWriter myWriter = new StringWriter();
>>>> Marshaller m1 = new Marshaller( myWriter );
>>>> m1.marshal(builtin01);
>>>> System.out.println( "Castor Output:" );
>>>> System.out.println( myWriter.getBuffer().toString() );
>>>> System.out.println( "" );
>>>> }
>>>> catch( Exception e ) {
>>>> e.printStackTrace();
>>>> }
>>>> }
>>>> }
>>>>
>>>> Castor validation works fine with string and integer types, while once
>>>> I input the following instance with invalid boolean type, castor
>>>> doesn't raise any validation exception but treat wrong input as false:
>>>> <?xml version="1.0"?>
>>>> <BuiltinElement>
>>>> <StringElement>abc</StringElement>
>>>> <IntegerElement>111</IntegerElement>
>>>> <BooleanElement>whatever</BooleanElement>
>>>> </BuiltinElement>
>>>>
>>>> Castor Output:
>>>> <?xml version="1.0" encoding="UTF-8"?>
>>>> <BuiltinTypes xmlns="http://www.example.com/test">
>>>> <StringElement>abc</StringElement>
>>>> <IntegerElement>111</IntegerElement>
>>>> <BooleanElement>false</BooleanElement>
>>>> </BuiltinTypes>
>>>>
>>>> It seems castor in-object validation doesn't validate boolean type
>>>> well in this case. Is there anything wrong with my code or
>>>> configurations?
>>>>
>>>> Thanks,
>>>> Andrew
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe from this list, please visit:
>>>>
>>>> http://xircles.codehaus.org/manage_email
>>>>
>>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe from this list, please visit:
>>>
>>> http://xircles.codehaus.org/manage_email
>>>
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>> http://xircles.codehaus.org/manage_email
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
> http://xircles.codehaus.org/manage_email
>
>
>
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email