users@jaxb.java.net

On-demand-validation problem

From: <domakmail-informatique_at_yahoo.fr>
Date: Wed, 5 Jan 2005 17:30:00 +0100 (CET)

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