users@jax-ws.java.net

Validating mandatory parameters of XML using JAXB 2.0

From: <praveen.mar_at_wipro.com>
Date: Mon, 16 Apr 2007 22:55:02 +0530

Hi,

I am wondering how we can validate mandatory parameters in a schema as
part of un-marshalling.

I do have a set of JAXB generated classes from a schema which requires
some mandatory parameters. When I un-marshaled an XML input which does
not have these mandatory parameters, the unmarshaller never gave me any
error. Below is the code snippet that I am using.

                    //Create the context to the package which contains
interfaces generated
         //by binding compiler
         JAXBContext jc = JAXBContext.newInstance("test.management");
         
         //Create the object which controls the process.
         Unmarshaller unmarshaller = jc.createUnmarshaller();
         
         //Read from file
         SomeClass ob = (SomeClass)unmarshaller.unmarshal(new File(
"managementdoc.xml"));
         
I am wondering whether I have to specify any thing to the unmarshaller
or to JAXB binding compiler to make sure that the mandatory attributes
in XML are validated.

Praveen P
* E-mail praveen.mar_at_wipro.com





The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments.

WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.
 
www.wipro.com