Sandeep,

Have a look at 

http://castor.org/xml-faq.html#How-to-enable-XML-validation-with-Castor-XML

Whic explain how to use XML parser features (through a JAXP compliant XML 
parser) to enable XMl schema validation at parsing time. I would not know, 
though, if a validation error will cause a ValidationException at 
unmarshalling, or whether any such exception will be wrapped by a 
MarshallingException.

I hope this help
Werner

> -----Original Message-----
> From: Sandeep [mailto:[EMAIL PROTECTED] 
> Sent: Dienstag, 09. Jänner 2007 14:30
> To: [email protected]
> Subject: Re: [castor-user] SourceCodeGenerator vs Mapping.xml
> 
> Hello Werner,
> 
> I can see some descriptor classes when I generate classes 
> from schema and what I understand is those descriptors help 
> in validating.
> Now, If I dont generate classes from schema, can you tell me 
> (a small code snippet will be very helpful) how do I perform 
> the schema validation so that the unmarshall method throws a 
> ValidationException?
> 
> My preferences are nothing:-). There is this legacy server 
> code which responds to method calls over http (GET 
> /getJavaBeanXXX) and it returns a xml string. I am trying to 
> define schema for every java bean. So, all those beans are 
> already in place, I am trying to bypass our age-old xml 
> parser which guzzles time and memory like anything.
> Also, validation is done in our application, so I need to 
> automate that also. So, I thought to try out castor.
> 
> FYI, this is my first project related to xml.
> 
> ~Sandeep
> 
> On 1/9/07, Werner Guttmann <[EMAIL PROTECTED]> wrote:
> > Let me just try to clarify one thing: XML validation.
> >
> > With Castor XML, it is possible to ask for XML schema 
> validation durign unmarshalling (at parsing time) without 
> having Java classes generated from the XML schema. When 
> generating classes from an XML schema, it is possible for 
> Castor XML to perform validation at unmarshalling time 
> without delegating this task to the XML parser. Just trying 
> to make sure you understand the fine difference(s) here.
> >
> > Other than that, it all depends where your preferences are, 
> and what you want to achieve. Whether you are working 
> cross-platfrom, or not, whether you tend to see an XML schema 
> as the contract , or not.
> >
> > Werner
> >
> > > -----Original Message-----
> > > From: Sandeep [mailto:[EMAIL PROTECTED]
> > > Sent: Dienstag, 09. Jänner 2007 10:34
> > > To: [email protected]
> > > Subject: [castor-user] SourceCodeGenerator vs Mapping.xml
> > >
> > > Hi
> > >
> > > Which is better:
> > > 1. Define a schema for a java bean, auto-generate the source code 
> > > and get the validation done by castor while populating 
> the bean from 
> > > a xml instance.
> > >
> > > 2. Hand code the java bean. Define a mapping file. 
> Populate the java 
> > > bean from a xml instance through castor. I don't think I need to 
> > > define a schema here (correct me, if I am wrong)
> > >
> > > Advantage for 1) is validation of data types and values can be 
> > > performed by castor.
> > > Advantages for 2) are flexibility to add application 
> specific helper 
> > > methods to the bean, or when  you cannot touch the source for the 
> > > bean.
> > >
> > > Obviously, advantage of one is the disadvantage for the other.
> > >
> > > So, how can I get the best of both worlds? I want to hand code my 
> > > bean class (not use SourceCodegenerator). I want to define the 
> > > schema apart from the mapping so that castor can validate the xml 
> > > instance against the schema for both data types and some values.
> > >
> > >
> > > TIA
> > >
> > > ~Sandeep
> > >
> > > 
> --------------------------------------------------------------------
> > > - To unsubscribe from this list please visit:
> > >
> > >     http://xircles.codehaus.org/manage_email
> > >
> >
> > 
> ---------------------------------------------------------------------
> > To unsubscribe from this list please visit:
> >
> >     http://xircles.codehaus.org/manage_email
> >
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe from this list please visit:
> 
>     http://xircles.codehaus.org/manage_email
> 

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply via email to