Understanding XSLT transformations: Your Own `XML Transformation Utility` - Developing your own XML transformation utility (Page 4 of 6 )
To proceed with developing the utility, you need to work with two namespaces as follows:
Make sure that the “Reference” section also has the “System.xml” assembly included, along with your solution (generally it should be available by default). Modify your code so that it looks something like the following:
Private Sub btnTransform_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTransform.Click
' Load the style sheet.
Dim xslt As New XslCompiledTransform()
' Create the writer.
Dim settings As New Xml.XmlWriterSettings()
settings.Indent = True
settings.IndentChars = vbTab
Dim sw As New IO.StringWriter
Dim writer As XmlWriter = XmlWriter.Create(sw, settings)
' Execute the transformation.
Me.txtTransformResult.Text = sw.ToString
After completing the above code, just execute it (by pressing F5) and provide the file names (along with paths) of both “Sample1.xml” and “Sample1.xsl”. Once you click on the “Transform” button, it should show a result something like the following (Fig 2):
And thus you can look at “live” and realistic transformation rather than simply seeing the output. The next section shall give you a detailed explanation of the above.