I am very new to saxon. I am trying to call external .net function from XSLT. Below is my code. I have implemented SaxonChartRenderer.dll using net.sf.saxon.function.ExtensionFunctionDefinition . But when try to register it in processor it is giving me type mismatch error.
Which can be due to different namespace of Saxon.Api and net.sf.saxon.
In net.sf.saxon namespace I am not able to find Processor class. I have searched it internet but not able to find any solution for this. Now I posting this here. How can we implement this?
using net.sf.saxon;
using Saxon.Api;
XmlReader xmlReader = XmlReader.Create(sourceUri);
            XmlReader xslReader = XmlReader.Create(xsltUri);
                // Create a Processor instance.
                Processor processor = new Processor();
                // Load the source document.
                //XdmNode input = processor.NewDocumentBuilder().Build(new Uri(sourceUri));
                XdmNode input = processor.NewDocumentBuilder().Build(xmlReader);
                // Create a transformer for the stylesheet.
                //XsltTransformer transformer = processor.NewXsltCompiler().Compile(new Uri(xsltUri)).Load();
                XsltTransformer transformer = processor.NewXsltCompiler().Compile(xslReader).Load();
                // Set the root node of the source document to be the initial context node.
                transformer.InitialContextNode = input;
                Assembly asm = Assembly.LoadFrom(@"C:\Projects\Projects\SaxonTestApp\extensions\SaxonChartRenderer.dll");
                object extObject = asm.CreateInstance("ChartRenderer.SaxonChartRenderer");
                if (extObject is net.sf.saxon.functions.ExtensionFunctionDefinition)
                    processor.RegisterExtensionFunction(extObject as ExtensionFunctionDefinition);
                transformer.SetParameter(new QName(new XmlQualifiedName("ibase")), new XdmAtomicValue(@"C:\Projects\Projects\SaxonTestApp\Images\"));
                transformer.SetParameter(new QName("", "", "ixsl"), new XdmAtomicValue(@"C:\Projects\Projects\SaxonTestApp\xsl\"));
                transformer.SetParameter(new QName("", "", "xmlfragment"), new XdmAtomicValue("//result[@type=\"practice:TimeSeries\"]"));
                transformer.SetParameter(new QName("", "", "vtype"), new XdmAtomicValue("monthly_revenue"));
                transformer.SetParameter(new QName("", "", "xs"), new XdmAtomicValue("actual;goal;"));
                // Create a serializer.
                StringBuilder output = new StringBuilder();
                StringWriter writer = new StringWriter(output);
                Serializer serializer = new Serializer();
                serializer.SetOutputProperty(Serializer.INDENT, "yes");
                // Transform the source XML to System.out.
                this.textBox1.Text = output.ToString();
            catch (Exception ex)
                this.textBox1.Text = ex.Message;
Parag Saxena

Important Notice to Recipients:


It is important that you do not use e-mail to request, authorize or effect the purchase or sale of any security or commodity, to send fund transfer instructions, or to effect any other transactions.  Any such request, orders, or instructions that you send will not be accepted and will not be processed by Morgan Stanley Smith Barney.


The sender of this e-mail is an employee of Morgan Stanley Smith Barney LLC. If you have received this communication in error, please destroy all electronic and paper copies and notify the sender immediately.   Erroneous transmission is not intended to waive confidentiality or privilege.  Morgan Stanley Smith Barney reserves the right, to the extent permitted under applicable law, to monitor electronic communications. By e-mailing with Morgan Stanley Smith Barney you consent to the foregoing.