Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using SaxonHE10Net31 .net 6 project #1

Open
mserioli opened this issue Oct 13, 2022 · 2 comments
Open

using SaxonHE10Net31 .net 6 project #1

mserioli opened this issue Oct 13, 2022 · 2 comments

Comments

@mserioli
Copy link

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

  • SaxonHE10Net31 10.8.0-alpha6
  • SaxonHE10Net31Api 10.8.0-alpha6

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
Copy link
Owner

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
Copy link
Author

Sorry, after some tweak I managed to making it work

Thank you again and compliments for your work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants