// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Xml; using System.Xml.XPath; using System.Xml.Xsl; namespace E { public class Program { public class BookUtils { public BookUtils() {} public string ShowText() { return "This came from the ShowText method!"; } } public static void Main(string[] args) { XPathDocument doc = new XPathDocument(@"C:\books.xml"); XslCompiledTransform trans = new XslCompiledTransform(); trans.Load(@"C:\books.xsl"); XsltArgumentList argBook = new XsltArgumentList(); BookUtils bu = new BookUtils(); argBook.AddExtensionObject("urn:XslSample", bu); XPathNavigator nav = doc.CreateNavigator(); trans.Transform(nav, argBook, Console.Out); } } }