You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Lefty Burgess <le...@red-bean.com> on 2000/06/15 21:23:55 UTC
getting all errors from validation
Hey all,
I am writing a servlet tool which sole purpose is take an XML file and
validate it. The Xerces and Xalan lists have been invaluable in
cluing me into successful validation; so my question is not about
validation per se.
My question involves how to get my servlet to list *all* errors when
an XML fails validation.
I am using xerces-1.0.3 and xalan-1.0.1. I have tried two different
methods, but in either one, I just get one error at a time.
The first method is to use Xerces alone. I instantiate a DOMParser
(or a SAXParser, either works), set the ErrorHandler and the
appropriate features.
The second method is to use Xalan. I instantiate a XercesLiason, set
the ErrorHandler and UseValidation.
The first works better in that I get more detailed exception messages
when validation fails.
Anyway, I am stumped as to how to go about getting the parser to
continue spamming errors.
Is the idea here to short-circuit the exception catching/throwing in
such a manner that the parser continues generating errors and does not
kill the servlet? Or is there something deeper I am missing?
Thanks.
--
Lee P. W. Burgess <<!>> "I shall flow a river forth to Thee,
Programmer <<!>> And filled with souls shall it ever be.
Red Bean Software <<!>> In nomine Patris, et Filii, et Spiritus Sancti."
lefty@red-bean.com <<!>> -- The Boondock Saints
getting all errors from validation
Posted by Lefty Burgess <le...@red-bean.com>.
I figured it out!
Basically, it was just what I thought it was:
Since my servlet was the ErrorHandler, I needed to modify the error(),
warning() and fatalError() methods so that they themselves did not
actually throw exceptions. Rather, I created a private PrintWriter
instance variable to which I assigned response.getWriter(). Then I
just write out every error I encounter while parsing.
(Still getting used to Java.)
- Lefty
Lefty Burgess writes:
>
> Hey all,
>
> I am writing a servlet tool which sole purpose is take an XML file and
> validate it. The Xerces and Xalan lists have been invaluable in
> cluing me into successful validation; so my question is not about
> validation per se.
>
> My question involves how to get my servlet to list *all* errors when
> an XML fails validation.
>
> I am using xerces-1.0.3 and xalan-1.0.1. I have tried two different
> methods, but in either one, I just get one error at a time.
>
> The first method is to use Xerces alone. I instantiate a DOMParser
> (or a SAXParser, either works), set the ErrorHandler and the
> appropriate features.
>
> The second method is to use Xalan. I instantiate a XercesLiason, set
> the ErrorHandler and UseValidation.
>
> The first works better in that I get more detailed exception messages
> when validation fails.
>
> Anyway, I am stumped as to how to go about getting the parser to
> continue spamming errors.
>
> Is the idea here to short-circuit the exception catching/throwing in
> such a manner that the parser continues generating errors and does not
> kill the servlet? Or is there something deeper I am missing?
>
> Thanks.
>
> --
> Lee P. W. Burgess <<!>> "I shall flow a river forth to Thee,
> Programmer <<!>> And filled with souls shall it ever be.
> Red Bean Software <<!>> In nomine Patris, et Filii, et Spiritus Sancti."
> lefty@red-bean.com <<!>> -- The Boondock Saints
>
>
>
>
--
Lee P. W. Burgess <<!>> "I shall flow a river forth to Thee,
Programmer <<!>> And filled with souls shall it ever be.
Red Bean Software <<!>> In nomine Patris, et Filii, et Spiritus Sancti."
lefty@red-bean.com <<!>> -- The Boondock Saints
getting all errors from validation
Posted by Lefty Burgess <le...@red-bean.com>.
I figured it out!
Basically, it was just what I thought it was:
Since my servlet was the ErrorHandler, I needed to modify the error(),
warning() and fatalError() methods so that they themselves did not
actually throw exceptions. Rather, I created a private PrintWriter
instance variable to which I assigned response.getWriter(). Then I
just write out every error I encounter while parsing.
(Still getting used to Java.)
- Lefty
Lefty Burgess writes:
>
> Hey all,
>
> I am writing a servlet tool which sole purpose is take an XML file and
> validate it. The Xerces and Xalan lists have been invaluable in
> cluing me into successful validation; so my question is not about
> validation per se.
>
> My question involves how to get my servlet to list *all* errors when
> an XML fails validation.
>
> I am using xerces-1.0.3 and xalan-1.0.1. I have tried two different
> methods, but in either one, I just get one error at a time.
>
> The first method is to use Xerces alone. I instantiate a DOMParser
> (or a SAXParser, either works), set the ErrorHandler and the
> appropriate features.
>
> The second method is to use Xalan. I instantiate a XercesLiason, set
> the ErrorHandler and UseValidation.
>
> The first works better in that I get more detailed exception messages
> when validation fails.
>
> Anyway, I am stumped as to how to go about getting the parser to
> continue spamming errors.
>
> Is the idea here to short-circuit the exception catching/throwing in
> such a manner that the parser continues generating errors and does not
> kill the servlet? Or is there something deeper I am missing?
>
> Thanks.
>
> --
> Lee P. W. Burgess <<!>> "I shall flow a river forth to Thee,
> Programmer <<!>> And filled with souls shall it ever be.
> Red Bean Software <<!>> In nomine Patris, et Filii, et Spiritus Sancti."
> lefty@red-bean.com <<!>> -- The Boondock Saints
>
>
>
>
--
Lee P. W. Burgess <<!>> "I shall flow a river forth to Thee,
Programmer <<!>> And filled with souls shall it ever be.
Red Bean Software <<!>> In nomine Patris, et Filii, et Spiritus Sancti."
lefty@red-bean.com <<!>> -- The Boondock Saints