[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

How to implement date difference in XSLT 1.0

Subject: How to implement date difference in XSLT 1.0
From: abhilash k <abhilash_bmc@xxxxxxxxx>
Date: Tue, 29 Sep 2009 22:00:17 +0530 (IST)
 How to implement date difference in XSLT 1.0
Hi Guys...need your help in below explained XML to CSV transformation.

Input:
-------
<Result>
   <Timesheet>
    <ID>888001</ID>
    <Name>Abhi</Name>
    <Week_Ending_Date>9/1/09</Week_Ending_Date>
    <Dept>Test Department</Dept>
    <Hours_Basic_Saturday>5:00</Hours_Basic_Saturday>
    <Hours_Basic_Sunday>0:00</Hours_Basic_Sunday>
    <Hours_Basic_Monday>9:00</Hours_Basic_Monday>
    </Timesheet>
</Result>   
           
Desired Output:
-----------------
The CSV file should have multiple records depending on days worked and
--> Word date as a date value derived from 'Week_End_Date' which is always a
friday date. i.e if Week_End_Date is 02/10/2009, Work date for Monday should
be derived by something like date(Week_End_Date) - 4.

Any idea how can i implement such date functions in XSLT 1.0 to get the below
given output.

ID,     Name, Week Ending, Dept,    Work Date, Reg Hours
888001, Abhi, 2/10/09, Test Department,26/09/09 , 5:00
888001, Abhi, 2/10/09, Test Department,28/09/09 , 9:00

Intermediate XSLT:
-----------------
I'm using this xslt which gives me the above output but don't have the date
logic yet.

<xsl:stylesheet
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   version="1.0">
   <xsl:output method="text"/>
   <xsl:param name="sep" select="', '"/>
   <xsl:param name="lf" select="'
'"/>

   <xsl:template match="/">
        <xsl:value-of select="concat('ID', $sep, 'Name', $sep,'Week Ending',
$sep, 'Dept', $sep,'Work Date',$sep,'Reg Hours', $lf)"/>
   <xsl:for-each select="Result/Timesheet">
   <xsl:if test="string(@Hours_Basic_Saturday) != '0.00'">
<xsl:value-of select="concat(ID, $sep, Name,$sep, Week_Ending_Date,$sep, Dept,
$sep,'',  $sep,Hours_Basic_Saturday,$lf)"/>
</xsl:if>
       
   <xsl:if test="string(@Hours_Basic_Sunday) != '0.00'">
    <xsl:value-of select="concat(ID, $sep, Name,$sep, Week_Ending_Date,$sep,
Dept, $sep,'',  $sep,Hours_Basic_Saturday, $lf)"/>
</xsl:if>
</xsl:for-each>
   </xsl:template>
</xsl:stylesheet>

Many Thanks,
Abhilash



      Keep up with people you care about with Yahoo! India Mail. Learn how.
http://in.overview.mail.yahoo.com/connectmore

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2011 All Rights Reserved.