You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Dan Tarkenton <ta...@gmail.com> on 2004/07/02 23:32:48 UTC

[Digester] Why aren't SAXExceptions thrown?

Hello, I'm as confused as possible.  I'm using Digester 1.5 binaries.

Below is a snippet of cod from my TestResultsHandler class:

public static void parse(String document) throws TestResultsException {
		
        Digester digester = initializeParser();

        TestResultsHandler resultsParser = null;
        try {
        
        //resultsParser = (TestResultsHandler)digester.parse(new
StringReader(document));
        resultsParser = 
        	(TestResultsHandler)digester.parse(new
File("/usr/local/projects/BOMAnalysis/web/xml/TestResults.xml"));
        } catch (SAXParseException saxe) {
	    	String msg = MessageUtil.formatMessage(MSG_TEST_RESULTS_PARSER_FAILURE);
	    	throw new TestResultsException(msg, saxe);
    	} catch (SAXException saxe) {
	    	String msg = MessageUtil.formatMessage(MSG_TEST_RESULTS_PARSER_FAILURE);
	    	throw new TestResultsException(msg, saxe);
    	} catch (IOException ioe) {
	    	String msg = MessageUtil.formatMessage(MSG_TEST_RESULTS_IO_FAILURE);
	    	throw new TestResultsException(msg, ioe);
	    	 
    	}
    }

Now, I intentionally try and break my TestResults.xml so that it will
throw a SAXParseException.  I'm trying to test for this case.  Below
is part of my log file:

2004-07-02 17:18:42,587: ERROR : Parse Error at line 30 column -1:
Element "TestResult" does not allow text.
org.xml.sax.SAXParseException: Element "TestResult" does not allow text.
	at org.apache.crimson.parser.Parser2.error(Parser2.java:3354)
	at org.apache.crimson.parser.ValidatingParser$ChildrenValidator.text(ValidatingParser.java:355)
	at org.apache.crimson.parser.InputEntity.parsedContent(InputEntity.java:597)
	at org.apache.crimson.parser.Parser2.content(Parser2.java:2010)
	at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1691)
	at org.apache.crimson.parser.Parser2.content(Parser2.java:1963)
	at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1691)
	at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:667)
	at org.apache.crimson.parser.Parser2.parse(Parser2.java:337)
	at org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:448)
	at org.apache.commons.digester.Digester.parse(Digester.java:1532)
	at com.titan.bat.gui.testresults.TestResultsHandler.parse(Unknown Source)
	at detailedReport_2._jspService(detailedReport_2.java:86)
	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java)
	at org.apache.tomcat.facade.ServletHandler.doService(ServletHandler.java:574)
	at org.apache.tomcat.core.Handler.invoke(Handler.java:322)
	at org.apache.tomcat.core.Handler.service(Handler.java:235)
	at org.apache.tomcat.facade.ServletHandler.service(ServletHandler.java:485)
	at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:917)
	at org.apache.tomcat.core.ContextManager.service(ContextManager.java:833)
	at org.apache.tomcat.modules.server.Http10Interceptor.processConnection(Http10Interceptor.java:176)
	at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:494)
	at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:516)
	at java.lang.Thread.run(Thread.java:534)

What gives here?  It certainly is running into a SAXParseException,
but it doesn't seem to be throwing it. I.e.  i never get a
TestResultsException.

Do I need to configure something else?  I looked at the API and I
thought I had this set to validate against my DTD.  I'm in desparate
need of help!

TIA.

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: [Digester] Why aren't SAXExceptions thrown?

Posted by Dan Tarkenton <ta...@gmail.com>.
I'm so ignorant.  I fixed the problem earlier by implementing an
ErrorHandler class, and to make sure the implementations actually
threw the SAXExceptions.  On top of not figuring this out, I forgot to
include the relevant part of my code in which I configured the
Digester object.

Oh well, I suppose I was frustrated at the time.

Thanks for the response!

On Sat, 03 Jul 2004 15:03:22 +1200, Simon Kitching
<si...@ecnetwork.co.nz> wrote:
> 
> 
> On Sat, 2004-07-03 at 09:32, Dan Tarkenton wrote:
> > Hello, I'm as confused as possible.  I'm using Digester 1.5 binaries.
> >
> >
> > Now, I intentionally try and break my TestResults.xml so that it will
> > throw a SAXParseException.  I'm trying to test for this case.  Below
> > is part of my log file:
> >
> > What gives here?  It certainly is running into a SAXParseException,
> > but it doesn't seem to be throwing it. I.e.  i never get a
> > TestResultsException.
> >
> > Do I need to configure something else?  I looked at the API and I
> > thought I had this set to validate against my DTD.  I'm in desparate
> > need of help!
> 
> Hi Dan,
> 
> You probably need to define a class which implements
> org.xml.sax.ErrorHandler and pass an instance of your class to the
> digester via
>   digester.setErrorHander(eh);
> 
> Digester extends org.xml.sax.helpers.DefaultHandler, and the default
> implementation it inherits from there is to completely ignore errors
> reported during parsing.
> 
> If you search the email archives, you should find some additional
> information on this topic.
> 
> Regards,
> 
> Simon
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: [Digester] Why aren't SAXExceptions thrown?

Posted by Simon Kitching <si...@ecnetwork.co.nz>.
On Sat, 2004-07-03 at 09:32, Dan Tarkenton wrote:
> Hello, I'm as confused as possible.  I'm using Digester 1.5 binaries.
>  
> 
> Now, I intentionally try and break my TestResults.xml so that it will
> throw a SAXParseException.  I'm trying to test for this case.  Below
> is part of my log file:
> 
> What gives here?  It certainly is running into a SAXParseException,
> but it doesn't seem to be throwing it. I.e.  i never get a
> TestResultsException.
> 
> Do I need to configure something else?  I looked at the API and I
> thought I had this set to validate against my DTD.  I'm in desparate
> need of help!

Hi Dan,

You probably need to define a class which implements
org.xml.sax.ErrorHandler and pass an instance of your class to the
digester via
  digester.setErrorHander(eh);

Digester extends org.xml.sax.helpers.DefaultHandler, and the default
implementation it inherits from there is to completely ignore errors
reported during parsing.

If you search the email archives, you should find some additional
information on this topic.

Regards,

Simon


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org