martin-honnen / SaxonHE10Net31

Sample project cross-compiling Saxon HE 10 with IKVM to .NET 3.1 core
Mozilla Public License 2.0
2 stars 1 forks source link

using SaxonHE10Net31 .net 6 project #1

Open mserioli opened 2 years ago

mserioli commented 2 years ago

I used Saxon-HE in my old .net framework projects. Now I'm developing a new project with .net 6 and discovered Saxon-HE is no more usable. I discovered you project and installed the following from nuget

I use this code to perform the xslt transform ` using Saxon.Api; [...] public static string XSLTtransform(string XsltPath, string InputXml) { Processor processor = new Processor(false); using (StringReader sr = new StringReader(InputXml)) { DocumentBuilder db = processor.NewDocumentBuilder();

            db.BaseUri = new Uri(XsltPath);
            XdmNode input = db.Build(sr);
            XsltTransformer myXslTrans = null;

            myXslTrans = processor.NewXsltCompiler().Compile(new Uri(XsltPath)).Load();

            myXslTrans.InitialContextNode = input;
            //myXslTrans.BaseUri = new Uri(XsltPath);
            myXslTrans.BaseOutputUri = new Uri(XsltPath);
            Serializer serializer = processor.NewSerializer();
            using (StringWriter sw = new StringWriter())
            {
                serializer.SetOutputWriter(sw);
                myXslTrans.Run(serializer);
                return sw.ToString();
            }
        }`

I get this exception

System.IO.FileNotFoundException: 'Could not load file or assembly 'Saxon.HE, Version=10.8.0.0, Culture=neutral, PublicKeyToken=13235d27fcbfff58'. Cannot find specified file.'

Am I missing something?

Thans for your support

martin-honnen commented 2 years ago

See the samples project https://github.com/martin-honnen/SaxonHE10Net31/blob/master/SaxonHE10Net31Samples/SaxonHE10Net31Samples.csproj, you need to make sure you also include

<ItemGroup>
    <PackageReference Include="IKVM.Maven.Sdk" Version="1.0.1" />
    <MavenReference Include="net.sf.saxon:Saxon-HE" Version="10.8" />
  </ItemGroup>

as that way the Java version of Saxon HE is pulled from the Maven repository and cross-compiled with IKVM for .NET core and the created dll is then available in your project.

mserioli commented 2 years ago

Sorry, after some tweak I managed to making it work

Thank you again and compliments for your work.