using Saxon.Api;
var xslt = new FileInfo(@"C:\path\to\stylesheet.xslt");
var input = new FileInfo(@"C:\path\to\data.xml");
var output = new FileInfo(@"C:\path\to\result.xml");
// 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);
Created
November 19, 2017 17:24
-
-
Save giansalex/32d3c5105a76728fff1ab8601c8603d6 to your computer and use it in GitHub Desktop.
Saxon c# xslt2 transform
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment