users@jaxb.java.net

Re: ValidationEventHandler returns only parent object through ValidationEvent.getLocator().getObject()

From: jon gold <dev_at_samizdatdigital.org>
Date: Wed, 29 Sep 2004 12:21:11 -0700

one possibility would be to allow users to customize the validation
messages through external bindings. ie, i could do something like
        
   <xsd:element name="foo" type="xsd:string">

     <jxb:validationDirective>
       <jxb:onMissing value="Need a 'foo'"/>
       <jxb:onInvalid value="'foo' must contain the string 'blubber'"/>
     </jxb:validationDirective>

     <xsd:restriction>
       <xsd:pattern value=".*blubber.*"/>
     </xsd:restriction>

   </xsd:element>

then xjc could either create it's raw validator to put that in the
ValidationEvents. the ValidationEvent class could be augmented with
getCustomizedMessage(), so we can create our own validation failure
messages, etc.

jon

Kohsuke Kawaguchi wrote:
> Aleksei Valikov wrote:
>
>> I'm also interested in on-demand validation that would, for instance,
>> allow displaying detailed validation messages in a document editor.
>
>
> The problem that I have with this is that the JAXB on-demand validation
> is still based on XML validation. So errors are all found in terms of XML.
>
> For example, when you are missing the city property, the error is
> actually "unexpected <zip-code> element: <city> expected", and it just
> doesn't naturally translate to the level of errors that the application
> developers would be looking for (such as "property city is missing from
> this Address object, along with enough information to let him put the
> focus on the right Swing component.)
>
> Plus then there's an issue of further translating those errors to
> user-level error messages (such as "please type in a proper city name".)
> Furthermore, it is a very common for schemas to leave out some of the
> constraints.
>
> Another thing is, those constraint checks on objects are by no means
> limited to JAXB --- you could have the same problem with Hibernate, for
> example.
>
> Yet another problem is that this on-demand validation is the primary
> reason we have to require such a huge runtime jars. Essentially it
> amounts to implementing a custom schema validator, and that's just insane.
>
> I think it would be much nice if someone develops a framework to check
> constraints on a Java object graph. Then JAXB can produce a contraint
> set from a given schema. Such a framework would do a much better job of
> reporting errors, it would allow you to add more constraints, and it
> would have enough hook to connect errors to your application.
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
For additional commands, e-mail: users-help_at_jaxb.dev.java.net