Xsl Transform

The XslTransform class in the System.Xml.Xsl namespace provides you with the means to take an XML message and an XSLT transformation file and create a new version of the original XML message. There are two main methods in the XslTransform class that you will deal with: Load and Transform. The Load method pulls in the XSLT file that you want to use to perform your transformations. This file could be a part of your application or an available XSLT file located somewhere on the Internet.

The Transform method takes in an XM L file, applies the loaded XSLT file to it, and creates an output file that is the result of your transformation. To use the XslTransform class, you would create a new instance of this class, Load the XSLT file, and then Transform your source XML document like this:

Dim MyXslt As Xml.Xsl.XslTransform = New Xml.Xsl.XslTransform() MyXslt.Load(CType("http://myserver/MyXslt.xsl", String)) MyXslt.Transform(InputFile, OutputFile)

In this example, the MyXslt object is loaded with an XSLT file located on the myserver Web server. You can add XSLT files to your Visual Studio .NET solution, or you can create these files manually using any text editor, such as Windows Notepad. You will learn how to create your own customized transformation file in the Immediate Solutions section of this chapter.

0 0

Post a comment