... until the collector arrives ...

This "blog" is really just a scratchpad of mine. There is not much of general interest here. Most of the content is scribbled down "live" as I discover things I want to remember. I rarely go back to correct mistakes in older entries. You have been warned :)


.NET System.Xml

It is pretty easy to write extension functions for XSLT under .NET.  The following code performs a transformation that uses an extension function:

XslTransform xslt = new XslTransform();

XsltArgumentList arguments = new XsltArgumentList();
arguments.AddExtensionObject("urn:x", new Extension());
XPathDocument document = new XPathDocument("test.xml");
XmlTextWriter writer = new XmlTextWriter(Console.Out);
xslt.Transform(document, arguments, writer, null);

All of the public members of the extension class become available within the template as QNames whose prefix is mapped to the URI passed as the first argument to AddExtensionObject.  The following data types can be used as parameters or the return value:  String, Boolean, Double, XPathNavigator (for result tree fragments), and XPathNodeIterator (for node sets).

Blog Archive