cancel
Showing results for 
Search instead for 
Did you mean: 

Error in Current Date in XSLT Mapping

Former Member
0 Kudos

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.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

There is a standard date/time function available to use for date and time. Ideally, you should use the standard functions, if you have one.

For XSLT :

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

link : http://www.zvon.org/xxl/XSL-Ref/Tutorials/Date-Time/dt1.html

Thanks,

Pooja Pandey

Former Member
0 Kudos

Hi Pooja,

Above Functions will work in Version 2.0, But not in Version 1.0

Former Member
0 Kudos

Check :

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

henrique_pinto
Active Contributor
0 Kudos

Have you actually tested it?

I have successfully used several XSLT 2.0 functions within XI.

Even though it is only XSLT 1.0 compliant, it already implements several functions of the 2.0 spec (it just doesn't implement everything 2.0 states, so it's not fully 2.0 compliant).

Regards,

Henrique.

Former Member
0 Kudos

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

Former Member
0 Kudos

Hi All,

Thank you very much for your answers.

I have tried all the options in displaying current date and time in XI ( Using XSLT mapping )... and found one easy way to dispay Current Date and Time using Runtime Functions

For more informations regarding Runtime functions in XSLT

http://help.sap.com/saphelp_nw04/helpdata/en/73/f61eea1741453eb8f794e150067930/content.htm

/message/435521#435521 [original link is broken]

Finally XSLT map looks like

<xsl:stylesheet version="1.0"

xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:a="http://XYZ.eu.ABC.com">

<xsl:param name="TimeSent" />

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

<xsl:value-of select= "$TimeSent"/>

</a:Current DateTime>

</xsl:template>

</xsl:stylesheet>