You can always use an EntityResolver and repoint a request for a 'global' XML 
schema identifier to any file or InputSource convenient to you.

Werner

> -----Ursprüngliche Nachricht-----
> Von: S. Sharif [mailto:[EMAIL PROTECTED]
> Gesendet: Dienstag, 13. März 2007 17:27
> An: [email protected]
> Betreff: Re: AW: [castor-user] How to do XSD validation when the code was
> not generated by the Castor code generator
> 
> 
> Thank for the link.  But the problem is that in the
> example it validates an xml document against the XSD
> file specified in xsi:schemaLocation attribute of the
> root xml tag.
> 
> The xml documents that get submitted to my Java
> service do not have the XSD schemaLocation attribute
> specified.  When I receive the XML document, my Java
> code then needs to perform XSD validation based on a
> predefined path for the XSD file.  So I need to set
> the XSD file location programmatically, if you know
> what i mean.
> 
> I mean I need to do something like this:
> 
> 
> Mapping myMap = new Mapping();
> myMap.loadMapping( "po1Map.xml" );
> 
> Unmarshaller um1 = new Unmarshaller( myMap );
> um1.setSchemaLocation("http://www.example.com/PO1
> /project/schema/po1.xsd");
> PurchaseOrder po1 = (PurchaseOrder)um1.unmarshal(new
> FileReader(filename));
> 
> 
> Note: this assumes that the xsd file po1.xsd is
> located in the /project/schema/ folder.
> 
> 
> The problem is that there is no setSchemaLocation()
> method in the Unmarshaller class.  So is there any
> other way to do this?
> 
> Thanks.
> 
> 
> --- Werner Guttmann <[EMAIL PROTECTED]>
> wrote:
> 
> >
> http://www.castor.org/how-to-enable-xml-validation.html
> > should provide you with answers to your question.
> >
> > Werner
> >
> > > -----Ursprüngliche Nachricht-----
> > > Von: S. Sharif [mailto:[EMAIL PROTECTED]
> > > Gesendet: Dienstag, 13. März 2007 02:23
> > > An: [email protected]
> > > Betreff: [castor-user] How to do XSD validation
> > when the code was not
> > > generated by the Castor code generator
> > >
> > >
> > > Hi,
> > >
> > > I am not using the Castor code generator to
> > generate
> > > my Java classes.  Instead I have my own java
> > classes
> > > that I am marshalling and unmarshalling to/from
> > them
> > > using a Castor mapping file.
> > >
> > > But now I am faced with the problem of how to
> > perform
> > > the XSD validation.  I know that the Castor code
> > > generator generates each Java class with the
> > following
> > > code:
> > >
> > > /**
> > >  *
> > >  *
> > >  * @throws
> > org.exolab.castor.xml.ValidationException
> > > if this
> > >  * object is an invalid instance according to the
> > > schema
> > >  */
> > > public void validate()
> > > throws org.exolab.castor.xml.ValidationException {
> > >     org.exolab.castor.xml.Validator validator =
> > new
> > > org.exolab.castor.xml.Validator();
> > >     validator.validate(this);
> > > }
> > >
> > >
> > > and that this code performs the XSD validation on
> > the
> > > Java object using the ClassDescriptors and
> > > FieldDescriptors that were generated for that
> > object.
> > >
> > > But now how do I perform XSD validation when I
> > have my
> > > own Java classes (that were not generated by
> > Castor).
> > > Is there some Castor API that I can call and pass
> > to
> > > it the path to the XSD file, the Java object that
> > I
> > > want to validate, and also the Castor mapping
> > file,
> > > and then it performs the validation?
> > > Or how should I go about doing this?
> > >
> > > Thanks.
> > >
> > > -Saladin
> > >
> > >
> > >
> >
> **********************************************************
> > > * Saladin Sharif
> > > * e-mail:  [EMAIL PROTECTED]
> > > * Visit homepage @
> > http://gaia.ecs.csus.edu/~sharifs
> > >
> >
> **********************************************************
> > >
> > >
> > >
> > >
> >
> __________________________________________________________________________
> > > __________
> > > Don't pick lemons.
> > > See all the new 2007 cars at Yahoo! Autos.
> > > http://autos.yahoo.com/new_cars.html
> > >
> > >
> >
> ---------------------------------------------------------------------
> > > 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
> >
> >
> 
> 
> 
> 
> __________________________________________________________________________
> __________
> Expecting? Get great news right away with email Auto-Check.
> Try the Yahoo! Mail Beta.
> http://advision.webevents.yahoo.com/mailbeta/newmail_tools.html
> 
> ---------------------------------------------------------------------
> 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