ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> xsl-list
xsl-list
[xsl] Is there a way to catch Exceptions in xslt thrown from calling a Java function within Xalan ?
by Bill Riegel other posts by this author
Feb 27 2004 6:58PM messages near this date
Re: [xsl] What is the future of XSL-FO | [xsl] Re: Is there a way to catch Exceptions in xslt thrown from calling a Java function within Xalan ?
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
Thread:
Bill Riegel
Dimitre Novatchev

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved