These tutorials demonstrate selected features in ASP.NET version 2.0, but they are compatible with later versions of ASP.NET as well. For the current documentation, see the ASP.NET portal on the MSDN Web site.

 

 

   Welcome   |   ASP.NET   |   Web Services   |   Class Browser   
  |   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 XsltArgumentList 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

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

		
'Create an XsltArgumentList
Dim xslArg As New XsltArgumentList()

'Add an object to calculate the circumference of the circle.
Dim obj As New Calculate()
xslArg.AddExtensionObject("urn:myObj", obj)
VB

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

		
Dim processor As New XslCompiledTransform()
...
 'Create an XmlWriter to output to the console.   
Using writer As XmlWriter = XmlWriter.Create(Console.Out)
    'Transform the file.
    processor.Transform(filename, xslArg, writer)
End Using
VB

Summary

  1. The XsltArgumentList 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 XsltArgumentList object to the Transform method.



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