Patty-

Well, the second is for a different project, but it's nice to know
we're not the only ones with the issue :)  The item has definitely
bumped up my personal priority list, though I can't say how it will
move on the dev's list (things usually move quickly when patches are
submitted).

Looking at 746, I'm not sure any of my ideas will attack items 2 or 3
in the description, but I think getting Castor to continue parsing
shouldn't be a big issue.  I'll try to look into the problem.

Stephen


On 3/23/06, Parker, Patricia (Contr) <[EMAIL PROTECTED]> wrote:
> Stephen,
>
> I have found two issues in Jira, CASTOR-746 (Open, minor improvement
> 15-Apr-04) and WSTX-25 (Open, minor new feature, 03-Dec-05) that mention
> this issue.  More than that may exist.  Would it be possible to increase
> the priority?
>
> Thanks!
>
> Patty
>
> -----Original Message-----
> From: Stephen Bash [mailto:[EMAIL PROTECTED]
> Sent: Thursday, March 23, 2006 8:45 AM
> To: [email protected]
> Subject: Re: [castor-user] When unmarshalling, need Castor to validate
> entire document against schema instead of quitting after first
> validation error
>
> Patty-
>
> Unfortunately, I don't think you can replace the ErrorHandler in such a
> way that the change will stick.  When you call unmarshal, the
> Unmarshaller sets the error handler just before starting parsing.  So
> that means the fix needs to live inside Castor, unless we create a
> method for user-supplied ErrorHandlers.
>
> So looking into the problem briefly, it appears that the Castor
> ErrorHandler (implemented in UnmarshalHandler) simply throws a
> SAXException for all calls to the ErrorHandler (including warnings).
> We can probably make an option to "continue parsing on
> non-fatal-errors", which would log the exception text but not kill the
> parsing process.
>
> I had hoped that either the exception type was different for validation
> exceptions (so we can test if ex instanceof ValidationException), or
> that we could demote validation errors down to warnings using a parser
> feature.  Doesn't look like either one of those is possible, so I think
> we'll have to give the user the option to continue parsing when
> ErrorHandler.warning or ErrorHandler.error are called, and only kill
> parsing when ErrorHandler.fatalError is called.
>
> Anyone else who wants to chime in on this solution, please do (or
> comment on the Jira issue once it is found/created).
>
> Thanks,
> Stephen
>
> On 3/23/06, Parker, Patricia (Contr) <[EMAIL PROTECTED]> wrote:
> > Stephen,
> >
> > Thanks for your quick reply!  I'll check into Jira to see if an entry
> > has already been created.
> >
> > In the meantime, I have been trying to configure Castor's ErrorHandler
>
> > with one of my own in the following way:
> >
> >
> > LocalConfiguration.getInstance().getXMLReader().setErrorHandler(handle
> > r)
> > ;
> >
> > Where handler is my own implementation of an ErrorHandler class.  It
> > is also the class that calls Castor's unmarshal method.  I haven't had
>
> > any luck with it, but I'm still trying.
> >
> > Thanks again
> >
> > Patty
> >
> >
> >
> > -----Original Message-----
> > From: Stephen Bash [mailto:[EMAIL PROTECTED]
> > Sent: Thursday, March 23, 2006 8:26 AM
> > To: [email protected]
> > Subject: Re: [castor-user] When unmarshalling, need Castor to validate
>
> > entire document against schema instead of quitting after first
> > validation error
> >
> > Eek!  I retract everything I said, it really probably is something we
> > can control in Castor.  Patty, can you do a quick search in Jira to
> > make sure this issue doesn't already exist, and then create one so we
> > can keep track of the progress on the issue?
> >
> > Thanks,
> > Stephen
> >
> >
> > On 3/23/06, Stephen Bash <[EMAIL PROTECTED]> wrote:
> > > Patty-
> > >
> > > I'm not 100% sure, but I think this is really a parser issue.  I
> > > think
> >
> > > validation errors look like normal SAXExceptions to Castor, so there
>
> > > isn't really a way to recover...  But I'd be happy to be corrected.
> > > With that in mind, one parser feature you can look into is the
> > > following:
> > >
> > >    http://apache.org/xml/features/continue-after-fatal-error
> > >
> > > Unfortunately on the Xerces website, the following warning is
> > attached:
> > >
> > > "The behavior of the parser when this feature is set to true is
> > > undetermined! Therefore use this feature with extreme caution
> > > because the parser may get stuck in an infinite loop or worse."
> > >
> > > This is actually a fairly regularly requested feature, so please let
>
> > > us know if you find something that does the trick.
> > >
> > > Stephen
> > >
> > > On 3/22/06, Parker, Patricia (Contr) <[EMAIL PROTECTED]>
> wrote:
> > > >
> > > >
> > > > Hi
> > > >
> > > > I would like to validate my entire instance document against an
> > > > XML schema during the unmarshalling process and accumulate all the
>
> > > > validation exceptions so that I may send them back to the document
>
> > > > creator so they may all be fixed.  Right now, Castor is throwing
> > > > the
> >
> > > > first ValidationException and stopping the schema validation
> > > > process.  Is there a way to tell Castor to validate the entire
> > > > document before stopping (i.e. make a ValidationException a
> > non-fatal error)?
> > > >
> > > > My Castor driver method:
> > > >
> > > >                 //unmarshal xml
> > > >                 boolean isSuccessful = true;
> > > >
> > > >                 Reader toParse = new StringReader((String)
> > > > xmlToParse);
> > > >
> > > >                 try
> > > >                 {
> > > >                         Mapping mapping = new Mapping();
> > > >                         mapping.loadMapping(mapFileName);
> > > >                         Unmarshaller un = new
> > Unmarshaller(castorClass);
> > > >                         un.setMapping(mapping );
> > > >                         un.setWhitespacePreserve(true);
> > > >                         un.setValidation(true);
> > > >                         try
> > > >                         {
> > > >                                 castorVO = (AbstractCastorVO)
> > > > un.unmarshal(toParse);
> > > >                         }
> > > >                         catch (ValidationException ex)
> > > >                         {
> > > >
> > parserMessageList.add(ex.getMessage());
> > > >                         }
> > > >                         catch(MarshalException ex)
> > > >                         {
> > > >
> > parserMessageList.add(ex.getMessage());
> > > >                         }
> > > >
> > > >                         toParse.close();
> > > >                 }
> > > >
> > > >                 catch (IOException ex)
> > > >                 {
> > > >                         isSuccessful = false;
> > > >                         parserMessageList.add(ex.getMessage());
> > > >                 }
> > > >                 catch (MappingException ex)
> > > >                 {
> > > >                         isSuccessful = false;
> > > >                         parserMessageList.add(ex.getMessage());
> > > >                 }
> > > >                 catch (MarshalException ex)
> > > >                 {
> > > >                         isSuccessful = false;
> > > >                         parserMessageList.add(ex.getMessage());
> > > >                 }
> > > >
> > > >                 return isSuccessful;
> > > >
> > > >
> > > > My castor.properties settings:
> > > >
> > > > # True if xml documents should be validated by the SAX Parser #
> > > > org.exolab.castor.parser.validation=true
> > > >
> > > > # Per Patty - set to false when generating code # then set to true
>
> > > > for un/marshalling org.exolab.castor.parser.namespaces=true
> > > >
> > > >
> > > > # True if all documents should be validated by the marshalling
> > > > framework # org.exolab.castor.marshalling.validation=true
> > > > org.exolab.castor.unmarshalling.validation=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
> > > >
> > > > # Comma separated list of SAX 2 features that should be enabled #
> > > > for the default parser.
> > > > #
> > > > #org.exolab.castor.features=
> > > >
> > > > Thank you for your help
> > > >
> > > > Patty
> > >
> >
> > -------------------------------------------------
> > 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