cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nigel Whitaker <>
Subject XSP Error handling with SAX line & column numbers
Date Tue, 15 Jun 2004 14:00:10 GMT

I'm a new cocoon user trying to develop an XSP which accepts XML input
from the user.  Longer term I will add browser-upload capability, but
for the moment I'm just trying to handle XML entered into a HTML textarea.

When the XML is invalid the XSP generates an
org.apache.cocoon.ProcessingException with an
org.xml.sax.SAXParseException nested 2 levels down.  Inside the
SAXParseException is information about systemId, line and column
number that I want to present to the user.

I've read the concept docs on error handling
and have managed to unroll my exceptions down to the

    <map:selectors default="browser">
      <map:selector name="exception" 
        <exception class="org.apache.cocoon.ProcessingException" 
        <exception name="DXPE" 
class="com.deltaxml.api.DeltaXMLProcessingException" unroll="true"/>
        <exception name="ParseProblem" 

And then configure a specific error handler for "ParseProblem" s:

    <map:select type="exception">
      <map:when test="ParseProblem">
        <map:generate type="notifying"/>
        <map:transform src="saxerror.xslt">
          <map:parameter name="contextPath" value="{request:contextPath}"/>
        <map:generate type="notifying"/>
        <map:transform src="defaulterror.xslt">
          <map:parameter name="contextPath" value="{request:contextPath}"/>

My problem is that I cannot get at the line/column number details in
saxerror.xslt because the notifier generator at this point has
converted everything to CDATA (I added a logging transformer after the
notifying generator), so that the SAXParseException is just CDATA
within <error:extra.../>

I've seen the Wiki entry on ErrorHandling and in particular entry no 7
about getting the exception object, but this is done in the context of
an XSP, which is a different type of generator to the notifying one.
As I'd like to stay close to the standard error handling mechansism
I'd like to avoid mixing the generators for the different types of errors
because then I'd have 2 types of generators, and possibilities for look
and feel and other types of inconsistencies.

What I'd like to do,  I suppose, is get hold of the exception
as per the XSP example but then generate events as per the notifier
style.  Is the notifying generator easily configurable/extendable
to do this?  Or perhaps, should I convert all the error handling over
to XSPs where I have access to the raw exception Objects?

Any suggestions welcome or are there alternative approaches to
handling SAXParseExceptions which I've missed? 

Using:  Cocoon-2.1.5 (standard set of blocks)
        Solaris 9 08/03 on Sparc (with latest recommended patch cluster)
        Tomcat 5.0.19
        Apache 1.3.28

I think cocoon generally has an excellent architecture for what I'm
trying to do and would like to resolve this final hurdle.



Nigel Whitaker, "Change control for XML, in XML",

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message