1

I am having an .Net Core 3.1 Application and an XSLT 2.0 Script. The Script should now be executeted by the Application.

First I tried:

//Create a new XslCompiledTransform and load the compiled transformation.
        XslCompiledTransform xslt = new XslCompiledTransform();
        xslt.Load(typeof(Transform));

        // Execute the transformation and output the results to a file.
        xslt.Transform("books.xml", "discount_books.html");

But this just seems to work on .net framework and just for XSLT 1.0.

No I found the Nuget-Package Saxon-HE-fixedrefs, which should be compatible to .net core according to the desciption. But when compiling I get an error in my first line

Saxon.Api.Processor proc = new Saxon.Api.Processor();

"System.TypeInitializationException: "The type initializer for 'net.sf.saxon.Configuration' threw an exception."

FileNotFoundException: Could not load file or assembly 'System.Configuration.ConfigurationManager, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. "

Is there any workaround for this?

Gigalodon
  • 41
  • 1
  • 7
  • See https://stackoverflow.com/a/58931196/252228 for XmlPrime as an option, at least technically, you would need to get in touch with them about licensing or future releases. As for Saxon, I don't know what that fixedrefs project tried to fix, but my understanding is that Saxon on .NET relies on IKVM which was developed for the .NET framework and is not compatible with .NET core. Of course, within ASP.NET, it should be possible to write an ASP.NET framework Web API that your ASP.NET Core pages could use like another rest API. – Martin Honnen Aug 13 '20 at 12:55
  • Saxon-HE-fixedrefs was last released in 2016 and was said to work with "the .NET Core CLI tools 1.0.0-**preview2**". Why do you expect it to work with the current version of .NET Core, 4 years later? – Dimitre Novatchev Aug 14 '20 at 02:37

2 Answers2

2

You will have to contact the package owner, Max Toro, to find out why Saxon-HE-fixedrefs is not working as described. Although the package description claims it to be unmodified Saxonica code, it is not distributed or supported by Saxonica, and as far as we in Saxonica are concerned, we believe that Saxon does not work on .NET Core.

We're aware of the need for a version of Saxon that runs on .NET Core, and are pursuing various avenues to achieve this, but the IKVM technology we rely on doesn't support Core, and the original developer Jeroen Frijters is no longer maintaining it, so we can't make any promises.

Michael Kay
  • 147,186
  • 10
  • 83
  • 148
  • Jus to note, Max Toro is not the owner of https://www.nuget.org/packages/Saxon-HE-fixedrefs/, it is https://www.nuget.org/profiles/tflanitzer. Max Toro provided NuGet packages of Saxon HE for the .NET framework before Saxonica officially took over. – Martin Honnen Aug 13 '20 at 17:29
1

SaxonCS EE has been released and works with .NET 5 and .NET 6 (RC/preview) and that way allows using XSLT 3, XPath 3.1 and XQuery 3.1 with .NET Core. It is only available under a commercial license however, but you can test it with a trial license, download from Saxonica is at https://www.saxonica.com/download/dotnet.xml, also on NuGet as https://www.nuget.org/packages/SaxonCS/.

As XSLT 3.0 implemented by SaxonCS is backwards compatible to XSLT 2.0 you want to run it should be no problem to use SaxonCS to run XSLT 2.0 with .NET Core.

Martin Honnen
  • 149,505
  • 6
  • 83
  • 100