|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Calling java in xsl.
Hi
This is probably not the right language to use to describe what I want to do, but I am not that familiar with java (or for that matter xslt), so please bear with me. We are making calls to java in xml (using cocoon) and I am working on a generic template to get the current date, add an offset to it and then get the value-of the date in a specified format. Here is the code: <?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:java="http://xml.apache.org/xslt/java"
xmlns:cal="java.util.Calendar"
xmlns:sf="java.text.SimpleDateFormat"
exclude-result-prefixes="java"
>
<!--
Gets current date + offset in form ddMMMyyParams: offset days to add to current date --> <xsl:template name="offset_date_ddMMMyy"> <xsl:param name="offset"> <xsl:variable name="today" select="cal:getInstance()"/> <xsl:variable name="todayPlus" select="cal:add($today, 6, $offset)"/> <xsl:value-of select="java:format(sf:new('ddMMMyy'), cal:getTime($today))"/> </xsl:template> <!-- Gets current date in form MM/dd/yyyy --> <xsl:template name="offset_date_MMddyyyy"> <xsl:variable name="today" select="cal:getInstance()"/> <xsl:variable name="todayPlus" select="cal:add($today, 6, $offset)"/> <xsl:value-of select="java:format(sf:new('MM/dd/yyyy'), cal:getTime($today))"/> </xsl:template> </xsl:stylesheet> Now, what bothers me about this is the variable todayPlus which serves no purpose other than giving us an opportunity to call add. How can we avoid this useless call? Cheers. Kamal.
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








