Current Date in XSLT 1.0 Mapping

Hi All,
Very Good Morning...
I have one issue my XSLT mapping, One filed is required current date and time.But in XSLT 1.0 there is no standard date function. But XSLT 2.0 version is aviable.
I am using the XSLT1.0 version.i saw in SDN some threads are related to this issue. XSLT supported for Java extensions.
Upto now i am n't working with JAVA mapping. How i can create a JAVA extension and how i can import to Integration Respoistery....
Kindly give me suggestion about this issue.
Thank you very much.
Sateesh

Dear Sateesh,
Declare xlst variables at start of xsl program like below
                         <xsl:output method="xml" indent="yes"/>
     <xsl:variable name="today_formatted" select="java:java.text.SimpleDateFormat.new('yyyyMMdd')"/>
     <xsl:variable name="time_formatted" select="java:java.text.SimpleDateFormat.new('HHmmss')"/>
      and use them in xsl mapping
<xsl:value-of select="substring(concat(java:format($today_formatted, $date),$blanks),1,8)"/>
<xsl:value-of select="substring(concat(java:format($time_formatted, $date),$blanks),1,6)"/>
thanks,
madhu

Similar Messages

  • Current date in xslt mapping

    Hi,
    I've tried to get the current date in my xslt mapping.
    I've used the following xslt coding:
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:date="http://exslt.org/dates-and-times" extension-element-prefixes="date">
    <xsl:template match="/">
    <xsl:variable name="now" select="current-date()"/>
    </xsl:template>
    </xsl:stylesheet>
    In stylus studio everything is OK and i retrieve the current date.
    When i import the xslt in the mapping tool and test the mapping i get the following error:
    javax.xml.transform.TransformerException: com.sap.engine.lib.xml.util.NestedException: Function with name 'current-date' not found in context library. at com.sap.engine.lib.jaxp.TransformerImpl.transform(TransformerImpl.java:251)
    While directly using the current date functionality within the message mapping everything is OK too.
    Does anyone know which date-functionality is used within the message mapping within the Integration Builder and/or wich mapping to be used in xslt for a working scenario?
    Thnx in advance!

    Ok thnx, these anwers where very helpfull for me to solve this problem.
    I've awarded points for all your answers.
    For anyone interested later on, I needed the date in my XSLT mapping in the following format ddMMMyy.
    Finnally I used the following xslt to achieve this:
         <xsl:template name="currentDate" xmlns:cal="java:java.util.GregorianCalendar">
              <xsl:variable name="now" select="cal:getInstance()" />
              <xsl:variable name="day" select="cal:get($now, 5)" />
              <xsl:variable name="month" select="cal:get($now, 2) + 1" />
              <xsl:variable name="year" select="substring(string(cal:get($now, 1)), 3, 2)" />
              <xsl:variable name="month">
                   <xsl:choose>
                        <xsl:when test="$month=1">Jan</xsl:when>
                        <xsl:when test="$month=2">Feb</xsl:when>
                        <xsl:when test="$month=3">Mar</xsl:when>
                        <xsl:when test="$month=4">Apr</xsl:when>
                        <xsl:when test="$month=5">May</xsl:when>
                        <xsl:when test="$month=6">Jun</xsl:when>
                        <xsl:when test="$month=7">Jul</xsl:when>
                        <xsl:when test="$month=8">Aug</xsl:when>
                        <xsl:when test="$month=9">Sep</xsl:when>
                        <xsl:when test="$month=10">Oct</xsl:when>
                        <xsl:when test="$month=11">Nov</xsl:when>
                        <xsl:when test="$month=12">Dec</xsl:when>
                        <xsl:otherwise>INVALID MONTH</xsl:otherwise>
                   </xsl:choose>
              </xsl:variable>
              <xsl:choose>
                   <xsl:when test="$day &lt; 10">
                        <xsl:value-of select="concat(concat(concat('0',$day), $month), $year)"/>
                   </xsl:when>
                   <xsl:otherwise>
                        <xsl:value-of select="concat(concat($day, $month), $year)"/>
                   </xsl:otherwise>
              </xsl:choose>
         </xsl:template>

  • Error in Current Date in XSLT Mapping

    Hi Experts,
      I am having a problem in Dispaying the current Date and Time ( or System Date and Time ) .As per my Project Requirements I need do XSLT mapping
    My XSLT Mapping Looks like
    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:a="http://XYZ.eu.ABC.com">
    <xsl:template match="/">
    <a:A2A>
        <a:PNo>
             <xsl:value-of select="Path/Path/PNO"/>
       </a:PNo>
       <a:Rev>
             <xsl:value-of select="Path/Path/REVISION"/>
       </a:Rev>
       <a:Current Date>
             <xsl:value-of select= ""/>
       </a:Current Date>
       <a:Current Time>
             <xsl:value-of select= ""/>
       </a:Current Time>
    </xsl:template>
    </xsl:stylesheet>
    Can any one please let me is there is any function to  dispaly the Current Date and time.

    Hi ..
    I just tried executing both the maps.. Both of them excutes well in both XMLSpy and Stylus Studio .. But having below problems in Executing in PI
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
    <xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/>
    <xsl:template match="/aaa">
    <xxx>
    <xsl:value-of select="current-dateTime()"/>
    </xxx>
    </xsl:template>
    </xsl:stylesheet>
    Then I got the error
    javax.xml.transform.TransformerException: com.sap.engine.lib.xml.util.NestedException: Function with name 'current-dateTime' not found in context library.
    with
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:datetime="http://exslt.org/dates-and-times"
    exclude-result-prefixes="datetime">
    <xsl:template match="/">
    <currtime>
    <xsl:value-of select="datetime:dateTime()" />
    </currtime>
    </xsl:template>
    </xsl:stylesheet>
    I have got
    Unable to find resource http://exslt/org/dates-and-times.class (http://NAMESPACE Name) in the following software component versions: 0fe18820-410a-11dd-979b-dc8591374305

  • XSLT Mapping - Getting current date in XSLT version 1.0

    Hi,
    I want to fetch the system date and compare it with another date, say 06.04.2010.
    How can I do this in XSLT 1.0?
    Thanks & Regards,
    Aditi Naik

    Hi,
    I tried using the following code:
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:cal="java:java.util.GregorianCalendar">
         <xsl:output method="xml"/>
         <xsl:template name="currentDate" xmlns:cal="java:java.util.GregorianCalendar">
              <xsl:variable name="now" select="cal:getInstance()"/>
              <xsl:variable name="day" select="cal:get($now, 5)"/>
              <xsl:variable name="month" select="cal:get($now, 2)"/>
              <xsl:variable name="year" select="substring(string(cal:get($now, 1)), 3, 2)"/>
         </xsl:template>
    <Body>
              <xsl:choose>
              <xsl:when test="boolean(//*[local-name() = 'IRenvelope']/node()) and boolean($year = 2009) and boolean($month &gt; 11) and boolean($day &gt; 05))">
              </xsl:when>
              </xsl:choose>
    </Body>
    However, when I try to run this mapping I get the error "Invalid XPath Expression" in Altova.
    Can you please tell me exactly what is wrong with this code and how I can get around this?
    Thanks & Regards,
    Aditi Naik

  • XSLT 1.0 current date

    Hi,
    I had searched on SDN already and tried few codes without success.
    If somebody had already worked on current date function in XSLT mapping version 1.0, please share it.
    Thanks in advance,
    Venkat.
    PS: links I already referred.
    http://www.w3.org/TR/xpath-functions/#func-current-dateTime
    Error in Current Date in XSLT Mapping
    Re: XSLT Mapping - Getting current date in XSLT version 1.0
    Re: Current date in xslt mapping

    Hi,
    XSLT 1.0 does not provide any standard way to get the current date/time. You can call an extension function to do it (depends on your processor), or you can pass it to the stylesheet as the value of a parameter.
    current-date() and current-time(). For XSLT 1 you'll have to use the dates-and-times EXSLT extension package. Here's a usage example for XSLT 1:
    <xsl:stylesheet    xmlns:ex="http://exslt.org/dates-and-times"      extension-element-prefixes="ex">
            <xsl:value-of select="ex:date-time()"/>
    </xsl:stylesheet>
    Refer this for
    http://www.exslt.org/date/index.html

  • How to compare date in xslt

    hi
    i need to compare the date in xslt . i was not able to get the current date in xslt.. so i entered through parameter by java. now i have the current date and in xml i have two field fromdate and todate i need to compare that some data should display when current date comes between fromdate and todate. can u tell me how to do it .
    try to provide some code....
    i was looking for some format date function but could get it
    xsl:if test="data/fromdate > currdate and date/todate < currdate"
    it is not working becouse i am not able to convert my varriable to date type... may be
    please help
    anagh

    Hi,
    I am running into a same problem with xsl :-
    a) I need to generate the current date and store it in a field
    b) I have a date field with a End date entered by the user..
    I need the xslt to minus the current date from the enddate and show the number of days / weeks left.
    How can i do this ?
    Rgds,
    Manoj

  • How to add date in XSLT?

    All,
    soa version: 11.1.1.4
    There is a requirement for me to add date to the current date in XSLT.  I searched in 'Data functions', there I couldn't find any pre-defined functions.  How do I achieve it in XSLT?  Any help is appreciated.
    thanks
    sen

    Hi Sen,
    You can do this using the below:
    <xsl:value-of select="xp20:add-dayTimeDuration-to-dateTime(xp20:current-dateTime(),'P1D')"/>
    You can change the P1D based on the number of days you want to add.
    For example 3 days = P3D
    Thanks,
    Deepak.

  • How to Compare date with Current system date in XSLT mapping.

    Hello Experts
    In a XSLT mapping program, I hava a filed, ZZOB which is giving some date.
    which I need to compare with the current date.
    Condition-
    ZZOB is greater than current date or ZZOBLIG = NULL
    Then go further statements.
    how can i campare with the current date?
    Please help.
    Thanks
    Balaprasad

    This example may help:
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    version="1.0">
    <xsl:param name="currentDate"/>
        <xsl:variable name="firstDate" select="concat(substring($currentDate, 1,4),substring($currentDate, 6,2),substring($currentDate, 9,2))"/>
        <xsl:template match="/">
            <xsl:apply-templates select="//item"/>
        </xsl:template>
        <xsl:template match="item">
            <xsl:variable name="secondDate" select="concat(substring(submissionDeadline, 1,4),substring(submissionDeadline, 6,2),substring(submissionDeadline, 9,2))"/>
            <xsl:choose>
            <xsl:when test="$firstDate &gt; $secondDate">
                <xsl:call-template name="late"/>
                </xsl:when>
                <xsl:when test="$firstDate &lt; $secondDate">
                    <xsl:call-template name="ontime"/>
                </xsl:when>
                <xsl:when test="$firstDate = $secondDate">
                    <xsl:call-template name="same"/>
                </xsl:when>
                <xsl:otherwise>Monkeys<br /></xsl:otherwise>
            </xsl:choose>
        </xsl:template>
        <xsl:template name="ontime">
            This is on time
        </xsl:template>
        <xsl:template name="late">
            This is late
        </xsl:template>
        <xsl:template name="same">
            This is on time
        </xsl:template>
    </xsl:stylesheet>

  • Filter Idoc segment based on date in XSLT map

    Hi,
    In a Idoc to flat file XSLT mapping, I have a requirment to filter segment out of multiple segment occurance in HRMD_A idoc. Idoc has two date fields(actually string data, containing date in YYYYMMDD format) in the segment(end date and start date). I need to filter only one segment from multiple segments where current date falles within start and end dates (end date >= current date >= start date). Then map output fields from the filtered segment.
    Its easy doing it in graphical mapping, but its difficult to use graphical mapping here as the message structure are enormous. I dont have much hands on in XSLT but think many of you have been through this kind of requirement using XSLT. So holding my hope high :). Please suggest a logic for this, will be highly appretiated.
    Regards
    Suman.

    This functions will give you the current date:
    fn:current-dateTime()     => Returns the current dateTime (with timezone)
    fn:current-date()                 => Returns the current date (with timezone)
    fn:current-time()                 => Returns the current time (with timezone)
    To compare:
    fn:compare(comp1,comp2)
    fn:compare(comp1,comp2,collation)
    => Returns -1 if comp1 is less than comp2, 0 if comp1 is equal to comp2, or 1 if comp1 is greater than comp2 (according to the rules of the collation that is used)
    Example: compare('ghi', 'ghi')
    Result: 0
    Also I suggest working with an IF condition like this:
    <xsl:if test="price &gt; 10">
            <tr>
              <td><xsl:value-of select="title"/></td>
              <td><xsl:value-of select="artist"/></td>
            </tr>
          </xsl:if>
    Edited by: Kai Lerch-Baier on Apr 14, 2009 10:21 AM

  • How we can view convert data after XSLT mapping & before Graphical mapp

    Hello Friends,
    Currently i am working on XI standard content. In this client need some customization.
    In interface mapping, XSLT mapping on 1st position & Graphical mapping on 2nd position.
    As per my understanding 1st XSLT mapping will be exected then Graphical mapping.
    Can I see or check convert data from XSLT mapping.
    I want to check data between XSLT mapping & Graphical mapping.
    Kindly help me out.
    Regards,
    Narendra

    >
    Narendra GSTIT wrote:
    > I dont want to test standalone XSL Code.
    >
    > The data which I get from Source interface and after XSLT mapping I want to check this that my XSLT code is going well or not.
    >
    > i.e. check for proper input & get proper output.
    You have ro do standalone testing of the XSLT mapping.....Interface Mapping or Interface Determination will give you output message which will be that of message mapping (the last mapping)
    What is the issue in testing the XSLT mapping alone?...may be in Stylus Studio.
    Just ensure that XSLT mapping produces proper output and then this output message of XSLT is the input to your Message Mapping.....once the entire Interface mapping gets executed then it would mean that all the included mapping programs work fine.
    Regards,
    Abhishek.

  • How to display the current Date and time in xslt version 1

    i am using xslt version 1 .i want to display the current date and time in the output xml using xslt(Jdeveloper) ..i just added the namespace xmlns:xp20="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.Xpath20"
         xmlns:ns1="urn:oracle:integration:b2b:7D30046DC68A4FA689956D8241FA3B99">
    and used thsi function <xsl:value-of select = "xp20:current-date()"/>
    but it does not works for me ..help needed????
    Edited by: user9519185 on Jan 20, 2009 3:04 AM

    Use a formula: =NOW()
    Format the cell for Date and Time, with both the Date part and the Time part displayed. Format the two parts as you wish, using the choices in the Inspector's menus.
    The cell will update each time the table is recalculated.
    (Description is for Numbers '09 (Mac), Numbers for iOS will be similar, but not necessarly identical in details.)
    Regards,
    Barry

  • XSLT: Validate if date is before date of current date

    Hi everyone,
    we need to check condition in XSLT transformation that if a date is before the current date or not.
    its easy to do this in java but not finding anything to do this in xslt.
    If anyone knows this please provide any pointer.
    TIA,

    to put above question clearly:
    For example if i have a date say
         targetDate = 2015-03-02T00:00:00.000
    now i need to verify if this targetDate is before current date or not.
    If(targetDate>beforeCurrentDate)
         targetDate = targetDate - 1 Month

  • Current datetime in xslt

    Hi ,
    I want to get the current datetime during my xlst tranform. I used the below codes but can not get it .
    xslt 1.0
    <xsl:stylesheet ...
    xmlns:ex="http://exslt.org/dates-and-times" extension-element-prefixes="ex">
    <xsl:value-of select="ex:date-time()"/> ...
    </xsl:stylesheet>
    error i got: the function date-time() can not be found.
    xlst 2.0
    <xsl:value-of select="current-dateTime()"/>
    error i got : the function current-dateTime() can not be found.
    Does anyone know how i can solve this problem? Any example or suggestion is welcomed.
    Thanks in advance.
    Dennis

    If that piece of xslt has any chance to succeed, you have to do either one of the modification.
    [1] Either you change the version attribute to 2.0. Oracle xslt processor is one of the earliest to get xslt 2.0 support at the time it is still a working draft. I think current-dateTime() xslt 2.0 function should be supported.
    <xsl:stylesheet version="2.0"[2] There are quite a bit of oracle proprietary extensions there. Hence, if you understand the suggestion(s) all along, it should do the task without appealing to the other extensions which may have their own functions to get the current date-time. This is how you should do for a test, keeping the version="1.0" unchanged.
    <xsl:stylesheet version="1.0"
    xmlns:date="http://www.oracle.com/XSL/Transform/java/java.util.Date"
    xmlns:xref="http://www.oracle.com/XSL/Transform/java/oracle.tip.xref.xpath.XRefXPathFunctions"
    xmlns:xp20="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.Xpath20"
    xmlns:bpws="http://schemas.xmlsoap.org/ws/2003/03/business-process/"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:ora="http://schemas.oracle.com/xpath/extension"
    xmlns:ehdr="http://www.oracle.com/XSL/Transform/java/oracle.tip.esb.server.headers.ESBHeaderFunctions"
    xmlns:ns0="http://www.example.org"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:orcl="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.ExtFunc"
    xmlns:ids="http://xmlns.oracle.com/bpel/services/IdentityService/xpath"
    xmlns:hwf="http://xmlns.oracle.com/bpel/workflow/xpath"
    exclude-result-prefixes="xsl xsd ns0 xref xp20 bpws ora ehdr orcl ids hwf date ">
    <xsl:template match="/">
    ...etc
    <TimeStamp><xsl:value-of select="date:toString(date:new())"/></TimeStamp>
    ...etc
    </xsl:template>

  • After backup Restore in 2.2 - no current Data visible!!!

    Hello! 
    I´ve spent the last few days trying to get the 2.2 up and running. After multiple re do´s I´m at a loss how to further proceed. 
    I took a backup from our existing vmbased 2.1.2 (backup ... application NCS..) and then restored it to the new 2.2 VMWARE installation. 
    the log says that everything worked:
    Started at : Tue Feb 10 16:44:34 2015
    Initiating restore.  Please wait...
      Restore Started at 02/10/15 16:44:34
      Stage 1 of 9: Transferring backup file ...
      -- completed at 02/10/15 16:45:43
      Stage 2 of 9: Decrypting backup file ...
      -- completed at  02/10/15 16:50:41
      Stage 3 of 9: Unpacking backup file ...
      -- completed at  02/10/15 16:50:48
      Stage 4 of 9: Decompressing backup ...
      -- completed at  02/10/15 16:55:17
      Stage 5 of 9: Restoring Support Files ...
      -- completed at  02/10/15 16:55:19
      Stage 6 of 9: Restoring Database Files ...
       -- completed at  02/10/15 16:56:49
      Stage 7 of 9: Recovering Database ...
      -- completed at  02/10/15 17:25:38
      Stage 8 of 9: Updating Database Schema ...
                      Stage 1 of 5: Pre Migration Schema Upgrade ...
                                            -- completed at: 2015-02-10 17:45:05.653, Time Taken : 0 hr, 14 min, 22 sec
                      Stage 2 of 5: Schema Upgrade ...
                                    : This could take long time based on the existing data size.
                                            -- completed at: 2015-02-10 17:55:02.82, Time Taken : 0 hr, 9 min, 57 sec
                      Stage 3 of 5: Post Migration Schema Upgrade ...
                                            -- completed at: 2015-02-10 18:04:55.583, Time Taken : 0 hr, 9 min, 52 sec
                      Stage 4 of 5: Enabling DB Constraints ...
                                            -- completed at: 2015-02-10 18:06:04.474, Time Taken : 0 hr, 1 min, 4 sec
                      Stage 5 of 5: Finishing Up ...
                                            -- completed at: 2015-02-10 18:06:15.352, Time Taken : 0 hr, 0 min, 10 sec
      -- completed at  02/10/15 18:06:46
      Stage 9 of 9: Re-enabling Database Settings ...
       -- completed at  02/10/15 18:06:46
       Total Restore duration is: 01h:22m:12s
    INFO: Restore completed successfully.
    Starting PI Server... This may take some time
    Starting Prime Infrastructure...
    This may take a while (10 minutes or more) ...
    Prime Infrastructure started successfully.
    Finished at : Tue Feb 10 18:30:53 2015
    then I Resynced everything, wlc config, switch config, cleared browser cache, And restarted. The good point: The data is all there! Everything! Maps, ap locations, everything! I was baffeled. I wasn´t really used for restores on NCS/Prime going so well :D Thinking all is well, I started furthur in. And noticed that every client. Every 7300 of them was disassociated. If I choose a client that I know is on the network (my laptop..) it always says disassociated, and the last time seen was the time of the backup. Ok might need a while. Let it sit over night. STILL NOTHING.. If you click on the check box to show the client details, troubleshoot or anything - you just get the spinning cursor and nothing shows up. If you go in the maps, and click on a ap, then click on the client count - spinning cursor. Everything that has to do with current data - spinning cursor. 
    Then I restarted. Fresh 2.2 installation. Added a few devices, just to see that the data collection really works. And YEAH it did! So I thought it might be a problem with maybe the devices not being in the database, jada jada jada. So I imported a 100 devices with the discovery function. Which is working really well. And THEN I restored the backup, again all successful, and all data is there. 
    and this morning - still no current data available. 
    Has anybody come across this? and how do I solve this? I will be opening a tac too, but I was hoping you guys are faster :D 
    thanks alot for your help! 

    I love to see that 2.2 has been granted mind reading abilities. After I complained here, I restarted and resynced again.. and now.. ehm. it works. No Idea what I did different this time :(( But it seems to be working now. 
    The last attempt was to add devices before the restore.. and then 3-4 resyncs, and 2 restarts.. 

  • Can i get current date in XSL FO customized file with Apex 3.0??

    Hi Oracle staff,
    i have a problem with the insert of current date in customized layout's XSL FO file..
    I have just tried to insert current-time() function and js scripts....but nothing.....PDF,Word or HTML output file that's printed by Bi Publisher displays an error that says:"Content file not supported or damaged".
    Why???is Bi Publisher a XSLT processor that supports currrent date functions????.
    and if not.....how can i install a new processor in substitution of Bi Publisher/Apache FOP???
    Regards
    Emanuel

    Yes, you can click the title bar of any document (the down arrow) to access the current file name:

Maybe you are looking for

  • Neo2 Platnum - memory ratio issues, please help!

    hey all very strang stuff... just got a 3200+ winchester .90 CPU, its nice. also have 2x twinx corsair 3200 non LL ram. idea: I had in mind that since my ram doesnt OC very well (220 max) I was going to get the neo2 and play with the FSB and set the

  • Can any one tell me How to load data in matrix from user table

    Hi, we need to load data to matrix when page loads. After loading data we should add row to that matrix and update the values in database without effecting previous data. It should have functionality like UDO Default Form. Can any help me out in this

  • Problem in leave workflow working in ESS

    Dear All , I ahve modified standard workflow for leave WS12300111 . I have 2 levels of approval . The step which goes to approver is standard task TS12300097 which is calling DUMMY method of CL_PT_REQ_WF_ATTRIBS class . Now my problem is suppose 100

  • Timemachine

    I have just noticed, that the time machine, which saves to a western digital smart book, has only been backing up three shortcuts on my desktop, no other drives? any ideas? thank you JC

  • Vertical Menu position problem

    Hi everyone, I'm trying to figure out how to manage the position of a vertical menu aligned on the left of the page. I have a centered background image. Depending on the size of the browser window the position of the menu varies and appears off. How