cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Luca Morandini" <>
Subject Handling exceptions
Date Mon, 05 Nov 2001 10:36:59 GMT

	I was thinking about the way of handling exceptions which arise during an
XSL transformation.

	For instance, let suppose the user is trying to modify a database object
which has been locked by another user, and the stored procedure (called via
SQLTransformer) returns an error code: how could I steer the sitemap to let
an error pipeline being executed ?

	I'd like a mechanism to signal the pipeline that something strange has
happened, hence, I presume an ExceptionTransformer, which filters SAX events
and, when an <exc:notify> is found changes a session parameter could be

	Let me explain my idea using some snippet of code:

A) In sitemap.xmap:

<map:match name="wildcard" pattern="update-customer.xml">

	<!-- Run-of-the-mill DBMS invocation -->
	<map:generate type="file" src="docs/update-customer.xml"/>
	<map:transform type="sql">
		<map:parameter name="use-connection" value="orcl"/>

	<!-- *** proposed ExceptionTransformer*** -->
	<!-- Checks for errors and put 0 in exc-flag if none are found -->
	<map:transform type="exc"/>

	<!-- If errors were found, steers the pipeline towards an error page -->
	<map:select type="parameter">
		<map:parameter name="parameter-selector-test" value="{exc-flag}"/>
		<map:when test="0">
			<map:transform src="stylesheets/customer.xsl"/>
			<map:transform src="stylesheets/error-html.xsl"/>

	<map:serialize tyep="html"/>

B) In update-customer.xsl (after calling SQLTransformer on a stored

<xsl:template match="sql:intStatus[.='1']">
	<xsl:element name="exc:notify">
		<xsl:attribute name="exc:id">1</xsl:attribute>
		<xsl:attribute name="exc:message">Locked customer !</xsl:attribute>

	Does it make sense ?

Thanks in advance,

               Luca Morandini
               GIS Consultant

Please check that your question has not already been answered in the
FAQ before posting. <>

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

View raw message