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>

Similar Messages

  • 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

  • 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 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>

  • 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

  • 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

  • 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.

  • Xslt mapping can't get date from java

    I am trying to get the current date/time from java in my xsl mapping. I can't seem to get it to work. This is the code I am using in my xsl file.
    <IDField>
      <xsl:template name="currentTime" xmlns:date="java:java.util.Date">
    <xsl:value-of select="date:new()"/>
      </xsl:template>
    </IDField>
    also tried
    <xsl:value-of select="java:java.util.Date:new()"/>
    I simply want to put the current date time in the IDField. What am I doing wrong? I am currently getting back a xslt mapping error. Here's the error....
    Transformer configuration exception occurred when loading XSLT
    I've tried a few different ways, but none have worked. What I'm looking for is the specific code that would display the date/time.
            - Emmett

    I figured it out. The main problem was that I didn't have the following in this line....
    <xsl:stylesheet version="1.0" <b>xmlns:java="http://xml.apache.org/xslt/java" </b>xmlns:xsl="http://www.w3.org/1999/XSL/Transform" .....>
    Once I included xmlns:java="http://xml.apache.org/xslt/java" all the java functions were available. I also found the great date template. In case anyone wants to check it out here it is...
    <xsl:template name="today"
                  xmlns:cal="xalan://java.util.GregorianCalendar">
      <xsl:variable name="rightNow" select="cal:getInstance()" />
      <!-- The GregorianCalendar class counts months from zero
           so we have to add one to get the customary number -->
      <xsl:variable name="month" select="cal:get($rightNow, 2) + 1" />
      <xsl:variable name="day" select="cal:get($rightNow, 5) " />
      <xsl:variable name="year" select="cal:get($rightNow, 1)" />
      <xsl:value-of
       select="$year" />-<xsl:value-of
       select="$month" />-<xsl:value-of
       select="$day" />
    </xsl:template>
    I found this template here...
    http://cafeconleche.org/books/xmljava/chapters/ch17s03.html
               - Emmett

  • Sample XSLT code to Display the Current date and time

    Hi all,
    Please Let me know code to display the system date in my target in xslt mapping.
    I am trying fn:current-datetime() function for the same.but could not get how to use it .Is it  function right  function.If so please send me the examples on the same.
    Thanks and Regards,
    Srini

    hey
    use this date:date-time()
    also have a look at this
    http://www.w3.org/TR/xpath-functions/#func-current-dateTime
    thanx
    ahmad

  • Use data type enhancement in XSLT mapping in XI

    Hi Experts,
    I'm working on SNC and I need to add an element to a data type.  I have created a data type enhancemnet with the element in it.  Now I need to get this into my XSLT mapping.  I have tried creating a message type but the data type enhancement is not recognized.
    Are data type enhancements only for proxies?  Can they be used in an XSLT or graphical mapping in XI?
    Thanks
    David Pauley

    Upon further investigation I found that Data Type Enhancements can be used with any message mapping.  There are a couple of things that you must get right.  First when creating the Data Type Enhancement make sure you use the namespace for your custom SWC that you created.  Next make sure that in the Ehancement for Data Type you use the SAP supplied data type name and namespace.  It also seems that your data type enhancement name, mapping name, and operational mapping name must have the Z_ prefix.  Save and activate, then go to system which owns the enhancement and go to SPROXY, you should see your custom SWC and under that you should see your enhanced data type, mapping, and operational mapping.  Activate and modify methods as needed here.

  • 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 Mapping: how to calculate Week number of the year from given date

    Hi,
    I  have input as date, i need to know the Week number from that date in XSLT Coding.
    for Eg: if date is 29-12-2009 it should give 53rd week of the year.
    All answers will be appreciated.
    Regards,
    Mayank

    Hi add this statement to your XSLT Mappping
    <xsl:stylesheet version="1.0" xmlns:java="http://xml.apache.org/xslt/java" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="java">
    and use <xsl:template name="GetDateInLocal" xmlns:cal="xalan://java.util.GregorianCalendar"> in XSLT Mapping , write your logic.
    cheers,
    Raj

Maybe you are looking for

  • Discoverer portlet error: blob content is empty.

    I created 6 disco reports and some are giving error, Failed to retrieve an entry from the cache in the Discoverer Portlet Repository. The BLOB content is empty. This error only happens with certain users. The users can log directly into discoveer vie

  • Icons not working

    none of the icons on my desktop are  opening. I've done backup and restore still nothing opens Please Help...thank you

  • Blackberry won't receive all split text messages

    I have a blackberry pearl 8130 and its character length for text messages is 140 characters. so when someone sends me a message that is over this length my phone splits it into 2 separate messages. The problem is sometimes I will only receive 1/2 to

  • Running the mappings which were deployed using remote runtime.

    Hi EveryBody, I am using OWB 10GR2. My environment is like this. I have two oracle databases A and B. I have installed OWB Repository in both databases. Now i have created a mapping map1 in Repository A and deployed it to Respository B(remote run tim

  • DB control alert

    Hi, on a Win 2003 server I have about 8 DB , 10g R2 all with their own DB Control. Only one of them sends me un alert of a disk drive more than 90% used.This alert is not correct and disk was not used as such. 1-How to see why this wrong alert ? 2-Ho