on 06-09-2008 1:00 PM
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!
Hi,
<xsl:template name="currentTime"
xmlns:date="java:java.util.Date">
<xsl:value-of select="date:new()"/>
</xsl:template>
Go through this document
http://cafeconleche.org/books/xmljava/chapters/ch17s03.html
This link is also having the same problem please check
Please reward points
Thanks
Vikranth
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 < 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>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I tried using the code that you have given above. But I'm getting an 'Invalid Xpath Expression" error.
I have written 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 > 11) and boolean($day > 05))">
................
..........
.........
</xsl:when>
..............
..........
...........
</xsl:choose>
</Body>
Could you please tell me how I can get around this error?
Thanks & Regards,
Aditi Naik
Hi,
I tried using the code that you have given above. But I'm getting an 'Invalid Xpath Expression" error.
I have written 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 > 11) and boolean($day > 05))">
................
..........
.........
</xsl:when>
..............
..........
...........
</xsl:choose>
</Body>
Could you please tell me how I can get around this error?
Thanks & Regards,
Aditi Naik
use this date:date-time()
also have a look at this
http://www.w3.org/TR/xpath-functions/#func-current-dateTime
(or)
Better write the Java UDF and call it in the XSLT...Its even better
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
You are using an EXSLT function, the XSLT processor in XI is not supporting the functionality of date-time.
The other way of doing it is, if you are using XSLT 1.0 (which is the case with you) you will have to use a java extension. Else if you are using XSLT 2.0 then you can use the current-date() function available in the same.
regards
Sameer
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
<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>
<yyy>
<xsl:value-of select="current-date()"/>
</yyy>
<zzz>
<xsl:value-of select="current-time()"/>
</zzz>
</xsl:template>
</xsl:stylesheet>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
78 | |
10 | |
7 | |
6 | |
6 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.