Bug 50242 - Cannot use MSXSL format-date/format-time XPath extension functions on non-Windows platforms
Summary: Cannot use MSXSL format-date/format-time XPath extension functions on non-Win...
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.XML (show other bugs)
Version: 4.6.0 (C8)
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Marek Safar
URL:
Depends on:
Blocks:
 
Reported: 2016-12-16 17:41 UTC by Basil Hussain
Modified: 2016-12-20 23:06 UTC (History)
2 users (show)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Test case (4.71 KB, application/zip)
2016-12-16 17:41 UTC, Basil Hussain
Details
Sample of expected output (647 bytes, text/html)
2016-12-16 17:44 UTC, Basil Hussain
Details

Description Basil Hussain 2016-12-16 17:41:04 UTC
Created attachment 18910 [details]
Test case

It is not possible to use the MSXSL XPath extension functions ms:format-date() and ms:format-time() for formatting dates and times on non-Windows platforms (e.g. Linux), due to a dependency upon native Win32 API functions in the framework code that implements these XPath functions.

When trying to use these functions, a fatal exception of "System.EntryPointNotFoundException: GetDateFormat" (or GetTimeFormat) is thrown at the point of usage in the XSL template.

The offending code appears to reside in XsltFunctions.cs, which is apparently Microsoft's implementation carried across to Mono as-is. GetDateFormat() and GetTimeFormat() are native Win32 API functions imported from kernel32.dll, and are used to do the actual date/time formatting by the MSFormatDateTime() method (which implements the format-date and format-time XPath functions).

Steps to reproduce:

1. Compile attached test case project with XBuild.
2. Run the executable - i.e. mono MSXSLTest.exe.
3. Application crashes with unhandled exception as soon as first instance of format-date function is encountered in XSLT.

Mono version info:

Mono JIT compiler version 4.6.2 (Stable 4.6.2.7/08fd525 Mon Nov 21 12:09:11 UTC 2016)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
        TLS:           __thread
        SIGSEGV:       altstack
        Notifications: epoll
        Architecture:  x86
        Disabled:      none
        Misc:          softdebug
        LLVM:          supported, not enabled.
        GC:            sgen

Exception stack trace from test program:

[ERROR] FATAL UNHANDLED EXCEPTION: System.EntryPointNotFoundException: GetDateFormat
  at (wrapper managed-to-native) System.Xml.Xsl.Runtime.XsltFunctions:GetDateFormat (int,uint,System.Xml.Xsl.Runtime.XsltFunctions/SystemTime&,string,System.Text.StringBuilder,int)
  at System.Xml.Xsl.Runtime.XsltFunctions.MSFormatDateTime (System.String dateTime, System.String format, System.String lang, System.Boolean isDate) [0x00069] in <1140eab9e72948548294172a9716416d>:0
  at (wrapper dynamic-method) System.Object:<xsl:template match="/TestData"> (System.Xml.Xsl.Runtime.XmlQueryRuntime,System.Xml.XPath.XPathNavigator)
  at (wrapper dynamic-method) System.Object:<xsl:apply-templates> (System.Xml.Xsl.Runtime.XmlQueryRuntime,System.Xml.XPath.XPathNavigator)
  at (wrapper dynamic-method) System.Object:Root (System.Xml.Xsl.Runtime.XmlQueryRuntime)
  at (wrapper dynamic-method) System.Object:Execute (System.Xml.Xsl.Runtime.XmlQueryRuntime)
  at System.Xml.Xsl.XmlILCommand.Execute (System.Object defaultDocument, System.Xml.XmlResolver dataSources, System.Xml.Xsl.XsltArgumentList argumentList, System.Xml.Xsl.Runtime.XmlSequenceWriter results) [0x00023] in <1140eab9e72948548294172a9716416d>:0
  at System.Xml.Xsl.XmlILCommand.Execute (System.Object defaultDocument, System.Xml.XmlResolver dataSources, System.Xml.Xsl.XsltArgumentList argumentList, System.Xml.XmlWriter writer) [0x0005e] in <1140eab9e72948548294172a9716416d>:0
  at System.Xml.Xsl.XslCompiledTransform.Transform (System.Xml.XmlReader input, System.Xml.Xsl.XsltArgumentList arguments, System.Xml.XmlWriter results, System.Xml.XmlResolver documentResolver) [0x0000d] in <1140eab9e72948548294172a9716416d>:0
  at System.Xml.Xsl.XslCompiledTransform.Transform (System.Xml.XmlReader input, System.Xml.Xsl.XsltArgumentList arguments, System.Xml.XmlWriter results) [0x00010] in <1140eab9e72948548294172a9716416d>:0
  at MSXSLTest.Program.Main (System.String[] args) [0x00086] in <49567a3da15247a185659408a4bb8fd9>:0
Comment 1 Basil Hussain 2016-12-16 17:44:27 UTC
Created attachment 18911 [details]
Sample of expected output

Added sample of expected output from the test case program. (Not exactly, obviously - current date and time should be substituted in the relevant place.)
Comment 2 Marek Safar 2016-12-20 13:54:39 UTC
Fixed in master and Mono 4.8
Comment 3 Basil Hussain 2016-12-20 23:06:55 UTC
Thanks for the quick fix.

Will this be available on the alpha update channel for Debian & derivatives soon?

Notice (2018-05-21): bugzilla.xamarin.com will be switching to read-only mode on Thursday, 2018-05-25 22:00 UTC.

Please join us on Visual Studio Developer Community and GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs and copy them to the new locations as needed for follow-up. The See Also field on each Bugzilla bug will be updated with a link to its new location when applicable.

After Bugzilla is read-only, if you have new information to add for a bug that does not yet have a matching issue on Developer Community or GitHub, you can create a follow-up issue in the new location. Copy and paste the title and description from this bug, and then add your new details. You can get a pre-formatted version of the title and description here:

In special cases you might also want the comments:

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Note You need to log in before you can comment on or make changes to this bug.