on ‎2008 Jun 09 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!
Request clarification before answering.
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
| User | Count |
|---|---|
| 15 | |
| 9 | |
| 6 | |
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.