[xsl] Is there a way to catch Exceptions in xslt thrown from calling a Java function within Xalan ?

Subject: [xsl] Is there a way to catch Exceptions in xslt thrown from calling a Java function within Xalan ?
From: Bill Riegel <BRiegel@xxxxxxx>
Date: Fri, 27 Feb 2004 12:58:42 -0600

Have the template below that I use with Xalan. 
Its purpose is to read a date string in one format and convert to another
format. But if/when the input data does not match the input format an
exception is thrown and the entire translation stops. Is there a way to
catch the exception ?  

  <xsl:template name="dateReformatter"
xmlns:java="http://xml.apache.org/xslt/java";>
     <xsl:param name="inputDate"/>
     <xsl:param name="inputFormat" />
     <xsl:param name="outputFormat"/>
     <xsl:message>in date</xsl:message>

    <xsl:choose>
    <xsl:when test="function-available(
'java:java.text.SimpleDateFormat.parse' )">
    <xsl:message>doing date</xsl:message>
    <xsl:variable name="informatter"       
        select="java:java.text.SimpleDateFormat.new($inputFormat)"/>

    <xsl:variable name="date"       
        select="java:parse($informatter, $inputDate)"/>

    <xsl:variable name="outformatter"       
        select="java:java.text.SimpleDateFormat.new( $outputFormat )"/>

    <xsl:variable name="outdate"       
        select="java:format($outformatter, $date)"/>

    <xsl:value-of select="$outdate"/>
    </xsl:when>
    <xsl:otherwise>
         No Date
    </xsl:otherwise>
    </xsl:choose>
 </xsl:template>


Bill Riegel
LandMark Graphics
713-839-3388



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread