Hi Michael,

On Thu, Jun 11, 2009 at 6:25 PM, Michael Glavassevich
<mrgla...@ca.ibm.com>wrote:

> Hi Mukul,
>
> Mukul Gandhi <gandhi.mu...@gmail.com> wrote on 06/11/2009 07:45:20 AM:
>
> > Hi Hiranya,
> >
> > On Thu, Jun 11, 2009 at 4:05 PM, Hiranya
> > Jayathilaka<hiranya...@gmail.com> wrote:
> > > This approach seems to be working. It logs error messages when the XSD
> is
> > > invalid. But how do I know if something went wrong at Java code level?
> >
> > I do not understand the question, "if something went wrong at Java
> > code level?". There could be something wrong with the Schema, which
> > this Java program reports.
> > Could you please clarify what you mean.
> >
> > > Is there any return value or exception that I could capture in my code?
> >
> > I think, the code I posted utilizes the error handler configured with
> > the Schema loader, to report the errors.
>
> I didn't see that in the snippet you posted. If you want programatic access
> to error information then you need to explicitly register an error handler:
>
> DOMErrorHandler myErrorHandler = ...;
>
> XSImplementation xsImpl = (XSImplementation) registry.getDOMImplementation(
> "XS-Loader");
> XSLoader xsLoader = xsImpl.createXSLoader(null);
>
> DOMConfiguration config = xsLoader.getConfig();
> config.setParameter("error-handler", myErrorHandler); // <-- set the error
> handler
>

Thanks for the code snippet. This is what I was looking for - A way to
detect schema errors  programmatically  (in this case by registering a
custom error handler).

Thanks,
Hiranya

>
>
> XSModel xsModel = xsLoader.loadURI(xsdUri);
>
> > --
> > Regards,
> > Mukul Gandhi
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: j-dev-unsubscr...@xerces.apache.org
> > For additional commands, e-mail: j-dev-h...@xerces.apache.org
>
> Thanks.
>
> Michael Glavassevich
> XML Parser Development
> IBM Toronto Lab
> E-mail: mrgla...@ca.ibm.com
> E-mail: mrgla...@apache.org
>



-- 
Hiranya Jayathilaka
Software Engineer;
WSO2 Inc.;  http://wso2.org
E-mail: hira...@wso2.com;  Mobile: +94 77 633 3491
Blog: http://techfeast-hiranya.blogspot.com

Reply via email to