Home   |   QuickStart Welcome   |   ASP.NET   |   Web Services   |   How Do I...?   
  |   I want my samples in...      

How Do I...? Common Tasks QuickStart Tutorial

How Do I...Use an Extension Object in an XSLT Style Sheet?

The XmlArgumentList class contains XSLT parameters and XSLT extension objects. When passed into the Execute method, these parameters and extension objects can be invoked from style sheets.

VB ExtensionObject.exe
View Source
[This sample can be found at C:\DevFusion.Data\legacy\quickstart.developerfusion.co.uk\QuickStart\howto\samples\Xml\ExtensionObject\]

XSLT extension objects are added to the XmlArgumentList using the AddExtensionObject method. A qualified name and namespace URI are associated with the extension object at that time.

XmlArgumentList xslArg = new XmlArgumentList();

//Add an object to calculate the circumference of the circle.
Calculate obj = new Calculate();
xslArg.AddExtensionObject("urn:myObj", obj);

The following code creates the XSLT processor, compiles the style sheet, and executes the transformation. By passing in the XmlArgumentList object to the Execute method, the extension object is now usable by the XSLT processor.

XsltCommand myProcessor = new XsltCommand();
myProcessor.Execute(filename, new XmlUrlResolver(), xslArg, writer);


  1. The XmlArgumentList class extends XSLT functionality by allowing you to add extension objects and parameters.
  2. Use the AddExtensionObject method to add the extension object.
  3. Invoke the extension object in the style sheet.
  4. Pass the XmlArgumentList object to the Execute method.

Microsoft .NET Framework SDK QuickStart Tutorials Version 2.0
Copyright � 2004 Microsoft Corporation. All rights reserved.