I'm using Win7 and set my VSC# project to .NETFramework4.
Then download SaxonHE9-8-0-7N-setup.exe and install.
Then reference saxon9he-api.dll to C# project and using Saxon.Api;
And here's my program.cs:
static void Main(string[] args)
{
    var xslt = new FileInfo(Path.GetFullPath(Path.Combine(Environment.CurrentDirectory.ToString(), @"..\..\..")) + @"\TEST.xslt");
    var input = new FileInfo(Path.GetFullPath(Path.Combine(Environment.CurrentDirectory.ToString(), @"..\..\..")) + @"\TEST.xml");
    var output = new FileInfo(Path.GetFullPath(Path.Combine(Environment.CurrentDirectory.ToString(), @"..\..\..")) + @"\result.txt");
    var processor = new Processor();
    var compiler = processor.NewXsltCompiler();
    var executable = compiler.Compile(new Uri(xslt.FullName));
    var transformer = executable.Load();
    var serializer = new Serializer();
    FileStream outStream = new FileStream(output.ToString(), FileMode.Create, FileAccess.Write);
    serializer.SetOutputStream(outStream);
    using (var inputStream = input.OpenRead())
    {
        transformer.SetInputStream(inputStream, new Uri(Path.GetTempPath()));
        transformer.SetParameter(new QName("password"), new XdmAtomicValue("secret"));
        transformer.Run(serializer);
        outStream.Close();
    }
}
here's my TEST.xslt:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:math="http://www.w3.org/2005/xpath-functions/math"
    xmlns:map="http://www.w3.org/2005/xpath-functions/map"
    xmlns:array="http://www.w3.org/2005/xpath-functions/array"
    exclude-result-prefixes="xs math map array"
    version="3.0">
  <xsl:output method="json" indent="yes"/>
  <xsl:strip-space elements="*"/>
  <xsl:template match="root">
    <xsl:map>
      <xsl:map-entry key="local-name()">
        <xsl:apply-templates/>
      </xsl:map-entry>
    </xsl:map>
  </xsl:template>
  <xsl:template match="items">
    <xsl:variable name="items" as="item()*">
      <xsl:apply-templates/>
    </xsl:variable>
    <xsl:sequence select="map { local-name() : array { $items }}"/>
  </xsl:template>
  <xsl:template match="item">
    <xsl:sequence select="map { 'foo' : xs:integer(foo), 'bar' : string(bar) }"/>
  </xsl:template>
</xsl:stylesheet>
Before runing I receive two error message:
The element 'template' in namespace 'http://www.w3.org/1999/XSL/Transform' has invalid child element 'map'
and
The 'as' attribute is not declared.
When running I receive one error message:
Error in xsl:map-entry/@key TEST.xslt:FOTY0013: Cannot write a function item to an XML tree in built-in template rule for /root in the unnamed mode**
So what should I do to run this code without error?
 
     
     
     
    