Danny,

Castor will, by default, validate the object model prior to the marshalling process. If you're using the source generator then the generated descriptors contain some validation attributes that Castor will use during this validation process. If you're not using the source generator you'd have to create your own validators or validation step.

Castor's object model validation is not as "complete" as validating the XML itself with the parser, but it should provide you with the basic property level validation, so in your situation the strings that are too long should be validated by Castor's object model validation process.

If you open up the *Descriptor.java files you'll see the validation code to give you an idea of what Castor will validate against.

--Keith




Danny Collins wrote:
AHA! Yeah I am trying to go from Java->XML and get the same level of
validation that you would get when you go form XML->JAVA.

We are already exploring adding in our own validation step. I was just
hoping to leverage anything that castor provided.

thanks
Danny

On 10/13/05, Stephen Bash <[EMAIL PROTECTED]> wrote:

Danny-

Are you validating during xml->java or java->xml?  The properties given
tell the xml parser to validate against a given schema, but during
java->xml, I don't believe the parser is utilized (there might be an
option that I don't know about).  My first idea would be to generate the
xml from the java objects, and then run that xml through a validating
parser to determine if the xml conforms to the schema.

I should mention that I don't use the source generator much at all, so
there may be options in there to help with validation that I don't know
about.

Stephen


Danny Collins wrote:

OK - popped those attributes into my properties file - regenerated the
source code and the fed the objects a ton of invalid data - mainly
strings that are WAY too long and should fail validation and will if I
do

I've attached my castor properties file.

I am trying to validate an individual object in the castor graph -
that is a piece of the schema.

do I need to build out the entire object graph in order for it to
validate correctly?

Thanks again, you all are being very helpful!
Danny

On 10/13/05, Danny Collins <[EMAIL PROTECTED]> wrote:


SWEET! Thanks for pointing this out. I am going to give it a go
straight away and let you know if it works out for me!

Thanks again guys.

On 10/13/05, Werner Guttmann <[EMAIL PROTECTED]> wrote:


Yes, as recently added to the XML F.A.Q. (though not released yet):

<p>To enable XML validation at the parser level, please add properties
to your
<tt>castor.properties</tt> file as follows:</p>

<code>
      org.exolab.castor.parser.namespaces=true

org.exolab.castor.sax.features=http://xml.org/sax/features/validation,\

http://apache.org/xml/features/validation/schema,\

http://apache.org/xml/features/validation/schema-full-checking
</code>

<p>Please note that the example given relies on the use of Apache
Xerces, hence the
<tt>apache.org</tt> properties; similar options should exist for other
parsers.</p>


I hope this helps
Werner

wg> -----Original Message-----
wg> From: Danny Collins [mailto:[EMAIL PROTECTED]
wg> Sent: Thursday, October 13, 2005 3:49 PM
wg> To: [email protected]
wg> Subject: Re: [castor-user] Schema Validation
wg>
wg> My original thought was that a call to validate prior to
wg> Marshal would work. But that doesn't seem to do anything.
wg> Then I found a reference to a property in the
wg> castor.properties file called
wg>
wg> org.exolab.castor.marshalling.validation
wg>
wg> that I have tried with true and false to no avail.
wg>
wg> Any thing else that I should know about?
wg>
wg>
wg> TIA
wg> Danny
wg>
wg> On 10/13/05, Werner Guttmann <[EMAIL PROTECTED]> wrote:
wg> > Danny,
wg> >
wg> > No, you are not. How are you instructing the XML parser
wg> (via Castor)
wg> > to use XML Schema validation ?
wg> >
wg> > Werner
wg> >
wg> > wg> -----Original Message-----
wg> > wg> From: Danny Collins [mailto:[EMAIL PROTECTED]
wg> > wg> Sent: Wednesday, October 12, 2005 1:35 PM
wg> > wg> To: [email protected]
wg> > wg> Subject: [castor-user] Schema Validation
wg> > wg>
wg> > wg> Hello,
wg> > wg>
wg> > wg> I seem to be having problems getting the my objects validated
wg> > wg> against the schema - it seems to be able to tell me if I am
wg> > wg> missing required objects, but it doesn't seem to be able to
wg> > wg> validate other restrictions like maxlength. Am I
wg> misinterpreting
wg> > wg> the validation abilities?
wg> > wg>
wg> > wg>
wg> > wg> TIA
wg> > wg> Danny
wg> > wg>
wg> > wg> -------------------------------------------------
wg> > wg> If you wish to unsubscribe from this list, please
wg> send an empty
wg> > wg> message to the following address:
wg> > wg>
wg> > wg> [EMAIL PROTECTED]
wg> > wg> -------------------------------------------------
wg> > wg>
wg> > wg>
wg> >
wg> > -------------------------------------------------
wg> > If you wish to unsubscribe from this list, please send an empty
wg> > message to the following address:
wg> >
wg> > [EMAIL PROTECTED]
wg> > -------------------------------------------------
wg> >
wg> >
wg>
wg> -------------------------------------------------
wg> If you wish to unsubscribe from this list, please send an
wg> empty message to the following address:
wg>
wg> [EMAIL PROTECTED]
wg> -------------------------------------------------
wg>
wg>

-------------------------------------------------
If you wish to unsubscribe from this list, please
send an empty message to the following address:

[EMAIL PROTECTED]
-------------------------------------------------




------------------------------------------------------------------------

-------------------------------------------------
If you wish to unsubscribe from this list, please
send an empty message to the following address:

[EMAIL PROTECTED]
-------------------------------------------------

-------------------------------------------------
If you wish to unsubscribe from this list, please
send an empty message to the following address:

[EMAIL PROTECTED]
-------------------------------------------------




-------------------------------------------------
If you wish to unsubscribe from this list, please send an empty message to the following address:

[EMAIL PROTECTED]
-------------------------------------------------




-------------------------------------------------
If you wish to unsubscribe from this list, please send an empty message to the following address:

[EMAIL PROTECTED]
-------------------------------------------------

Reply via email to