Hi Celino,

Do take a look at the following sample for validation which might be useful - 
http://xmlbeans.apache.org/samples/Validation.html.

-Rajiv


-----Original Message-----
From: Celinio Fernandes [mailto:[EMAIL PROTECTED] 
Sent: Monday, August 01, 2005 6:26 AM
To: user@xmlbeans.apache.org
Subject: RE : Validate an XML file against a schema


I think I got it wrong, I should spend more time reading the API before
posting a question.

 boolean isValid = newEmp.validate(validateOptions); 
==> validates the XML file against the schema.

Can anyone quickly confirm this please ?

Sorry,
Thanks


-----Message d'origine-----
De : Celinio Fernandes [mailto:[EMAIL PROTECTED] 
Envoyé : lundi 1 août 2005 15:20
À : user@xmlbeans.apache.org
Objet : Validate an XML file against a schema


Hi,

How do you specify the name and location of the Schema file .xsd against
which the validate() method will validate the XML file ?

In the following example, where/how do you specify the name / location
of the schema .xsd file ?

 // Create an XmlOptions instance and set the error listener.
XmlOptions validateOptions = new XmlOptions();  ArrayList errorList =
new ArrayList();  validateOptions.setErrorListener(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++)
      {
          XmlError error = (XmlError)errorList.get(i);
          
          System.out.println("\n");
          System.out.println("Message: " + error.getMessage() + "\n");
          System.out.println("Location of invalid XML: " + 
              error.getCursorLocation().xmlText() + "\n");
      }
 }

Thanks


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to