users@jaxb.java.net

Re: On-demand-validation problem

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Wed, 05 Jan 2005 09:24:46 -0800

ValidationEvent object has a ValidationEventLocator, and for the JAXB RI
this Locator object should implement
com.sun.xml.bind.ValidationEventLocatorEx, which has the getFieldName
method.

I hope that will solve your problem.

domakmail-informatique_at_yahoo.fr wrote:
> Hi and happy new year,
>
> I have a xml file with a sequence of complexe types. I want to check simply some
> value elements and log an error with a record id (one of the element of my
> complex type). I can't do validation during the unmarshalling process cause I
> don't have the id yet. So I'm trying to validate-on-demand each java objects
> after the unmarshalling process. But, when I catch the ValidationException, I
> don't see the field that trigger the exception.
>
> Ex: I want to check that some values don't exceed 10 chars.
>
> <xs:simpleType name="stringLengthMax_10">
> <xs:restriction base="xs:string">
> <xs:maxLength value="10" />
> </xs:restriction>
> </xs:simpleType>
>
> When I invoke the Validator.validate() method, I got an exception like :
> class: class javax.xml.bind.ValidationException
> cause: null
> errorCode: null
> linkedException: com.sun.xml.bind.serializer.AbortSerializationException: the
> length of the value is 12, but the required maximum is 10.
> localizedMessage: null
> message: null
> stackTrace: [Ljava.lang.StackTraceElement;@1c54796
>
> But I don't have the name of the field (and in the debugger, I can see it in the
> context
> <my_generated_class>.impl.runtime.XMLSerializer passed to the MSVValidator).
>
> How can I retrieve the name of the field. Do I have to create my own validator
> and don't use the schema constraints?
>
> Thanks a lot,
>
> Christophe
>
> --------------------------------------------------------------------------------
> Découvrez le nouveau Yahoo! Mail : 250 Mo d'espace de stockage pour vos mails !
> Créez votre Yahoo! Mail
> <http://fr.rd.yahoo.com/mail/taglines/*http://fr.rd.yahoo.com/evt=25917/*http://fr.rd.yahoo.com/mail_fr/mail_campaigns/splash/taglines_250/default/*http://fr.promotions.yahoo.com/mail/creer28.html>
>


-- 
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
For additional commands, e-mail: users-help_at_jaxb.dev.java.net