2

Good day! I downloaded Altova XMLSpy trial, installed FOP 0.95 and tried to perform XSLT (version 1.0) transformation. My template is valid but during the transformation it fails on the line containing "date-time()" function:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:dt="http://exslt.org/dates-and-times" xmlns:exsl="http://exslt.org/common" extension-element-prefixes="dt exsl">
<xsl:output method="html" encoding="utf-8" indent="yes"/>

<xsl:template match="/">
    <html>
        <body>
            <xsl:value-of select="dt:date-time()"/>
        </body>
    </html>
</xsl:template>

</xsl:stylesheet>

The error message is:

Error in XPath expression
Unknown function - Name and number of arguments do not match any function signature in
the static context - 'http://exslt.org/dates-and-times:date-time'

Please how to make this function available? I'm sure this function exists. The template works for example in this online XSLT tester: http://markbucayan.appspot.com/xslt/index.html

Thank you in advance! Vojtech

UPDATE: I installed SAXON 9 (both HE and EE), configured ALTOVA to use it but again the same error.

Vojtech
  • 2,533
  • 9
  • 34
  • 65
  • When you say "the same error" do you mean the exact same wording? Because this is an Altova error message, so if you got this message, you were not running Saxon. Use system-property('xsl:vendor') to tell you which XSLT processor you are running. – Michael Kay Mar 14 '12 at 14:39
  • Thank you Michael. When I query vendor and version I get this: Vendor Saxonica, version 2.0. With the "same error" I mean the same error message as it is written in my question. – Vojtech Mar 14 '12 at 15:43

3 Answers3

4

If you are using Altova or saxon you can use XSLT2 rather than XSLT1 so do not need to load the EXSLT extensions, xpath2 has this function built in

select="current-dateTime()"

http://www.w3.org/TR/xpath-functions/#func-current-dateTime

David Carlisle
  • 5,582
  • 1
  • 19
  • 23
  • Thank you, unfortunately I use Altova just to develop a template which will be used in a web application which supports XSLT1 only. So I can't use XSLT2. – Vojtech Mar 14 '12 at 13:17
  • Well in that case you need to see if your web application supports the exslt extensions (which are not a standard part of xslt) or perhaps simpler for this case just declare the current date as a stylesheet parameter and pass it in to the stylesheet as a string calculated in the external hosting language. – David Carlisle Mar 14 '12 at 13:32
  • Thank you David. Yes, the web application supports EXSLT. I'm not owner of the application, I just have to develop a template for it. Because it is difficult usig tools provided with the web application I would like to develop it locally on my machine. Unfortunately it seems that EXSLT does not work on my machine and I don't know why. When I print information about vendor and version I get this: Vendor Saxonica, version 2.0. – Vojtech Mar 14 '12 at 15:41
  • Most of the exslt functions are _not_ supported in saxon (after saxon 6) because they are replaced by standard xpath2 functions. To test xslt1+exslt get a saxon6 installation. – David Carlisle Mar 14 '12 at 15:52
  • That's it! I installed Saxon 6.5.5 (which supports XSLT1) instead of Saxon 9 and it works now. Many thanks! – Vojtech Mar 15 '12 at 17:22
0
`<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" extension-element-prefixes="msxsl" xmlns:local="urn:local>
<msxsl:script language="CSharp" implements-prefix="local">


public string dateTimeNow()
    {       
      return DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ssZ"); 
    } 

</msxsl:script> </xsl:stylesheet>`

and then use it like this <xsl:param name="dnes" select="local:dateTimeNow()"/>

0

Please use Altova xml spy 9 version which support XSL 2.0.

Thanks Aditya

Aditya
  • 41
  • 1
  • 4
  • 1
    Please read the already accepted answer and it comments before posting one... You'll realize that the person who posted the question can't use XSL 2.0 – NREZ Jul 30 '13 at 09:25
  • The question contained the information of the version not restriction that's why i suggested. – Aditya Mar 10 '17 at 06:52