You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by Dutta Satadip <s-...@sbcglobal.net> on 2004/03/03 06:19:35 UTC

Retrieving Validation Errors Programatically

Hello,
 
A bug was filed for extracting errors programatically.( http://nagoya.apache.org/bugzilla/show_bug.cgi?id=27342)
Here is the attached patch for retrieving xml validation errors programatically.
 
the attached snippet can be used to extract the errors programatically
 

XmlOptions validateOptions = new XmlOptions();

ArrayList errorList = new ArrayList();

 validateOptions. setValidationErrorListener (errorList);

 

// Validate the XML.

boolean isValid = newEmp.validate(validateOptions);

     * 

     * // If the XML isn't valid, loop through the listener's contents,

     * // printing contained messages.

     * if (!isValid)

     * {

          for (int i = 0; i < errorList.size(); i++)

         {

             XmlValidationError error = (XmlValidationError)errorList.get(i);

             //extract details as necessary

 

         }

 
Hope this is useful
With Regards
Dutta:)


 



> ATTACHMENT part 2 application/x-zip-compressed name=changes.zip