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
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
- The XsltArgumentList class extends XSLT functionality by allowing you to add extension objects and parameters.
- Use the AddExtensionObject method to add the extension object.
- Invoke the extension object in the style sheet.
- Pass the XsltArgumentList object to the Transform method.
Microsoft .NET Framework SDK QuickStart Tutorials Version 2.0
Copyright � 2005 Microsoft Corporation. All rights reserved.
|