Home arrow XML arrow Page 4 - Understanding XSLT transformations: Your Own `XML Transformation Utility`

Understanding XSLT transformations: Your Own `XML Transformation Utility`

This article mainly concentrates on the basics of transforming XML documents, along with developing your own utility to transform XML to XSLT using Visual Studio 2005.

Author Info:
By: Jagadish Chaterjee
Rating: 5 stars5 stars5 stars5 stars5 stars / 7
December 28, 2005
  1. · Understanding XSLT transformations: Your Own `XML Transformation Utility`
  2. · Understanding the XML and XSLT
  3. · “XML transformation utility,” is it really necessary?
  4. · Developing your own XML transformation utility
  5. · Understanding the XML transformation utility
  6. · Testing further with different types of XML

print this article

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:

Imports System.Xml
Imports System.Xml.Xsl

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.
        xslt.Transform(Me.txtXMLFilePath.Text, writer)
        Me.txtTransformResult.Text = sw.ToString
    End Sub

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.

blog comments powered by Disqus

- Open XML Finally Supported by MS Office
- XML Features Added to Two Systems
- Using Regions with XSL Formatting Objects
- Using XSL Formatting Objects
- More Schematron Features
- Schematron Patterns and Validation
- Using Schematron
- Datatypes and More in RELAX NG
- Providing Options in RELAX NG
- An Introduction to RELAX NG
- Path, Predicates, and XQuery
- Using Predicates with XQuery
- Navigating Input Documents Using Paths
- XML Basics
- Introduction to XPath

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


© 2003-2019 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials