You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Luca Morandini <l....@tin.it> on 2001/11/05 11:36:59 UTC

Handling exceptions

Folks,

	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
handy.

	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"/>
	</map:transform>

	<!-- *** 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:when>
		<map:otherwise>
			<map:transform src="stylesheets/error-html.xsl"/>
		</map:otherwise>
	<map:select>

	<map:serialize tyep="html"/>
</map:match>

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

<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>
	</xsl:element>
</xsl:template>


	Does it make sense ?


Thanks in advance,

---------------------------------------------
               Luca Morandini
               GIS Consultant
              lmorandini@ieee.org
http://utenti.tripod.it/lmorandini/index.html
---------------------------------------------



---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>