XML
  Home arrow XML arrow Page 4 - Understanding XSLT transformations: Your O...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
XML

Understanding XSLT transformations: Your Own `XML Transformation Utility`
By: Jagadish Chaterjee
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 5
    2005-12-28

    Table of Contents:
  • Understanding XSLT transformations: Your Own `XML Transformation Utility`
  • Understanding the XML and XSLT
  • “XML transformation utility,” is it really necessary?
  • Developing your own XML transformation utility
  • Understanding the XML transformation utility
  • Testing further with different types of XML

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    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()
            xslt.Load(Me.txtXSLFilePath.Text)
     
            ' 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)
            writer.Close()
            Me.txtTransformResult.Text = sw.ToString
            sw.Close()
        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.

    More XML Articles
    More By Jagadish Chaterjee


       · Hello guys..you can try my simple "XML Transformation Utility" here and give me some...
     

    XML ARTICLES

    - 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
    - Simple Web Syndication with RSS 2.0
    - Java UI Design with an IDE







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek