Subject: Re: [xsl] What is best practice for dealing with errors in XSLT 1.0? From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Wed, 07 Apr 2010 11:00:23 -0400 |
While processing an input document, my XSLT transform discovered an error. What is the best way of dealing with that error?
One approach to dealing with errors is to sprinkle <xsl:message terminate="yes"> elements liberally throughout the XSLT document. But the behavior of <xsl:message terminate="yes"> varies from processor to processor. That's not appealing.
It would be nice if the XSLT transform could generate two result documents - one result document contains the "ordinary" output and the other result document contains descriptions of errors that were encountered during processing.
Alas, XSLT 1.0 does not provide the ability to generate multiple output files.
What's your suggestion for dealing with errors?
<xsl:variable name="error-message"> <xsl:call-template name="check-fatal-errors-1"/> <xsl:call-template name="check-fatal-errors-2"/> <xsl:call-template name="check-fatal-errors-3"/> <xsl:call-template name="check-fatal-errors-4"/> </xsl:variable> <xsl:if test="normalize-string($error-message"> <xsl:message terminate="yes"> <xsl:value-of select="$error-message"/> </xsl:message> </xsl:if>
<xsl:if test="something-bad-here"> <xsl:comment>fatal: <xsl:value-of select="stuff"/></xsl:comment> </xsl:if>
<xsl:if test="something-bad-here"> <myerror:fatal ref="123"><xsl:value-of select="stuff"/></myerror:fatal> </xsl:if>
-- XSLT/XQuery training: San Carlos, California 2010-04-26/30 Principles of XSLT for XQuery Writers: San Francisco,CA 2010-05-03 XSLT/XQuery training: Ottawa, Canada 2010-05-10/14 XSLT/XQuery/UBL/Code List training: Trondheim,Norway 2010-06-02/11 Vote for your XML training: http://www.CraneSoftwrights.com/s/i/ Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Male Cancer Awareness Nov'07 http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] What is best practice for dea, Costello, Roger L. | Thread | RE: [xsl] What is best practice for, Costello, Roger L. |
[xsl] What is best practice for dea, Costello, Roger L. | Date | RE: [xsl] Mandatory and Missing Col, Wendell Piez |
Month |