Hi Yuemin,
Is your point that v.validate(_PAYINFO) should simply return "false" if
it encounters a problem, instead of throwing an exception?
Regards,
--
Ed Mooney |Sun Microsystems, Inc.|Time flies like
Java Web Services |UBUR02-201 |an arrow, but
Ed.Mooney_at_Sun.COM |1 Network Drive |fruit flies like
781-442-0459 |Burlington, MA 01803 |a banana. Groucho
[1] http://java.sun.com/xml/downloads/jaxb.html
[2] http://java.sun.com/xml/jaxb/api/javax/xml/bind/Validator.html
[3] http://java.sun.com/xml/jaxb/users-guide/jaxb-using.html#sampapp5
Yuemin Wang wrote:
> Hi Ed,
>
> I have just downloaded the jaxb-1.0-beta and tried the same scenario, the
> problem is still there.
>
> Let me explain the problem more clearly:
> As we all know that an element with '?' in XML DTD file means 0 or 1, i.e.
> this element can be null or one. The correct validation logic for this
> element should be:
>
> 1. return OK -- if the element is empty ( == null)
> 2. return v.validate(_XXX) -- if the element is not empty
>
> But by using jaxb-1.0-ea or jaxb-1.0-beta to generate the java code, you
> will find the validation logic only contain the second one. That means even
> the DTD defined the element as '?' 0 or 1, but you if you ignore this
> element the validation will through exception. This why each time after I
> bind the java code from a DTD, I have to go through all the '?' elements
> java code to modify the "validate" method, and add the first logic manually,
> e.g.:
>
> from:
>
>>v.validate(_PAYINFO);
>
>
> to:
>
>>if ( _PAYINFO != null)
>> v.validate(_PAYINFO);
>
>
> Ed, If this is not clear, or my way to bind is not correct, please let me
> know.
>
> Thank you!
>
> Yuemin Wang
> ywang_at_todo1.com
> 786-331-0089
[ ... ]