I am programming in C#. I was previously using the following command line to convert an xml with a xsl and output it as a html.
java -jar "C:\Data\saxon-he-9.4.0.7.jar" View.xml Stylesheet.xsl -o:output.html
However, I am now trying to use the Saxon .Net API to do the same process using the following code:
var xslt = new FileInfo(@"C:\\Data\\Stylesheet.xsl");
var input = new FileInfo(@"C:\\Data\\View.xml");
var output = new FileInfo(@"C:\\Data\\test.html");
// Compile stylesheet
var processor = new Processor();
var compiler = processor.NewXsltCompiler();
var executable = compiler.Compile(new Uri(xslt.FullName));
// Do transformation to a destination
var destination = new DomDestination();
using (var inputStream = input.OpenRead())
{
var transformer = executable.Load();
transformer.SetInputStream(inputStream, new Uri(input.DirectoryName));
transformer.Run(destination);
}
// Save result to a file (or whatever else you wanna do)
destination.XmlDocument.Save(output.FullName);
However I recieve the error: "An unhandled exception of type 'Saxon.Api.DynamicError' occurred in saxon9he-api.dll" When running the line "transformer.Run(destination);"
The following screenshots are from the Visual Studio's Locals Debugging:
transformer {Saxon.Api.XsltTransformer} Saxon.Api.XsltTransformer