Support #5617
open
fn:format-dateTime does not work as expected
0%
Description
Hello, I am trying to use fn:format-dateTime to parse the date from date time format to another, but I am getting weird errors
following is the sample xslt I am using
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/2005/xpath-functions"
xmlns:func="http://ingka.ikea.com/"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:int="http://ikea.com/FUI/stockreport"
xmlns:date="http://www.w3.org/2005/xpath-functions"
version="3.0">
<xsl:output method="text" indent="yes" omit-xml-declaration="yes" />
<xsl:strip-space elements="*"/>
<xsl:param name="MessageReference" />
<xsl:template match="/">
<xsl:variable name="transformed-xml">
<xsl:call-template name="body" />
<xsl:copy-of select="/map"/>
</xsl:variable>
<!-- Added replace startment to print n/a as is, issue https://saxonica.plan.io/issues/5225-->
<xsl:value-of select="xml-to-json($transformed-xml, map { 'indent' : true() })"/>
</xsl:template>
<xsl:template name="body" >
<map>
<map key="MsgHeader">
<xsl:call-template name="MsgHeader"/>
</map>
</map>
</xsl:template>
<xsl:template name="MsgHeader" >
<string key="MsgNames"><xsl:value-of select="parse-dateTime('05/30/2018 09:00:00','MM/dd/yyyy HH:MMMX')"/></string>
<string key="MsgVersNo">1.0</string>
<string key="MsgDateTime"><xsl:value-of select="format-dateTime(current-dateTime(),'[Y0001]-[M01]-[D01]T[H01]:[m01]:[s01].[f001][Z00:00]')"/></string>
</xsl:template>
</xsl:stylesheet>
goal is to convert sample date time from 05/30/2018 09:00:00 to the standard format like "2018-05-30T09:00:00.000+02:00
So wanted to parse this date time, get into standard date time format and then finally using format-dateTime to get the required date time format.
but while using the above xslt, I keep getting error
Stylesheet compilation failed with 1 error(s): Error 1 at line 35:0 : Cannot find a 2-argument function named Q{http://www.w3.org/2005/xpath-functions}parse-dateTime(). External function calls have been disabled
Updated by Juhi Gupta 24 days ago
refering to documentation https://www.saxonica.com/html/documentation11/functions/fn/format-dateTime.html
Updated by Michael Kay 24 days ago
- Project changed from Non-Conformances to Saxon
Updated by Martin Honnen 24 days ago
Saxon PE and EE support https://www.saxonica.com/html/documentation11/functions/saxon/parse-dateTime.html so you would need to use e.g. saxon:parse-dateTime
(and PE or EE) instead of parse-dateTime
in your code. As the error message says, there is no XPath 2 or 3 function named parse-dateTime
.
Updated by Juhi Gupta 24 days ago
Ah, do you mean doing something like this:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/2005/xpath-functions"
xmlns:func="http://ingka.ikea.com/"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:int="http://ikea.com/FUI/stockreport"
xmlns:date="http://www.w3.org/2005/xpath-functions"
xmlns:saxon="http://saxon.sf.net/"
version="3.0">
<xsl:output method="text" indent="yes" omit-xml-declaration="yes" />
<xsl:strip-space elements="*"/>
<xsl:param name="MessageReference" />
<xsl:template match="/">
<xsl:variable name="transformed-xml">
<xsl:call-template name="body" />
<xsl:copy-of select="/map"/>
</xsl:variable>
<!-- Added replace startment to print n/a as is, issue https://saxonica.plan.io/issues/5225-->
<xsl:value-of select="xml-to-json($transformed-xml, map { 'indent' : true() })"/>
</xsl:template>
<xsl:template name="body" >
<map>
<map key="MsgHeader">
<xsl:call-template name="MsgHeader"/>
</map>
</map>
</xsl:template>
<xsl:template name="MsgHeader" >
<string key="MsgNames"><xsl:value-of select="saxon:parse-dateTime('05/30/2018 09:00:00','MM/dd/yyyy HH:MMMX')"/></string>
<string key="MsgVersNo">1.0</string>
<string key="MsgDateTime"><xsl:value-of select="format-dateTime(current-dateTime(),'[Y0001]-[M01]-[D01]T[H01]:[m01]:[s01].[f001][Z00:00]')"/></string>
</xsl:template>
</xsl:stylesheet>
its throwing back similar error *Stylesheet compilation failed with 1 error(s): Error 1 at line 36:0 : Cannot find a 2-argument function named Q{http://saxon.sf.net/}parse-dateTime(). External function calls have been disabled *
but I think it could be because I am using Saxon HE
Do you think this function would be available in Saxon HE anytime?
Updated by Michael Kay 24 days ago
It's our general policy that Saxon extensions to the W3C specifications require Saxon-PE or higher.
Please register to edit this issue