ASP.NET
  Home arrow ASP.NET arrow Developing XSLT-based Applications in ASP....
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
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? 
ASP.NET

Developing XSLT-based Applications in ASP.NET 2.0
By: Jagadish Chaterjee
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 20
    2006-12-04

    Table of Contents:
  • Developing XSLT-based Applications in ASP.NET 2.0
  • Testing XSLT using ASP.NET 2.0
  • Separating templates from the root template
  • Defining templates for particular tags
  • Working with all siblings available at a particular path
  • Transforming XML data to HTML tables using XSLT
  • Parsing through previous and next siblings using XSLT

  • 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


    Developing XSLT-based Applications in ASP.NET 2.0


    (Page 1 of 7 )

    This is the first article in a series focused on developing XSLT-oriented applications using ASP.NET 2.0. Even though the title includes ASP.NET 2.0, I use it only as a transformation engine. The entire focus will be on working with XSLT. You can use any transformation engine according to your requirements (such as Java or others).
    A downloadable zip file is available for this article.

    The entire solution (source code) for this article is available as a free download in the form of a zip file.  All the applications in this series have been developed using Microsoft Visual Studio 2005 Professional Edition on Microsoft Windows Server 2003 Standard Edition together with Microsoft SQL Server 2005 Developer Edition as the database. I didn’t really test any of the code in any of the other  tools/IDEs/servers/editions/versions.  If you have any problems, please feel free to post in the discussion area.

    How to transform XML to XSLT using ASP.NET 2.0

    Transforming XML to XSLT using ASP.NET 2.0 is quite easy. Working with the XML control (available in the toolbox) makes it easy to transform any XML document to the specified XSLT.

    As it is a bit tedious to always author XML documents, I simply converted the output of a result set (or dataset) to an XML document by using the following method:

    Private Function getXMLContent(ByVal SQL As String) As XmlDocument

        Dim ds As New DataSet("SQLData")

        Dim da As New SqlDataAdapter(SQL, "data source=laptop2k3sql2k5;initial catalog=AdventureWorks;user id=sa;password=eXpress2005")

        da.Fill(ds, "Rows")

        da.Dispose()

        Dim sw As New System.IO.StringWriter

        ds.WriteXml(sw)

        ds.Dispose()

        Dim docXML As New XmlDocument

        docXML.LoadXml(sw.ToString())

        sw.Close()

        Return docXML

      End Function

    The above method accepts a SELECT query and returns XML in the form of an object of type “XmlDocument.” You may need to modify the above method to suit your production requirements.

    Now, let us see how to transform the XML document to the specified XSLT.  The following is the code used to achieve the same:

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim docXML As XmlDocument = getXMLContent("select EmployeeID, FirstName, JobTitle from HumanResources.vEmployee")

        Me.txtXML.Text = docXML.InnerXml

        Dim xp As New XPath.XPathDocument(New XmlTextReader(New IO.StringReader(docXML.InnerXml)))

        Xml1.XPathNavigator = xp.CreateNavigator

        Xml1.TransformSource = Server.MapPath("XSLTFile01.xsl")

      End Sub

    To work with the above code, you need to drag and drop an XML control from the toolbox onto the web page.  You may have to modify the name of the XSLT file according to your design or theme.

    More ASP.NET Articles
    More By Jagadish Chaterjee


       · Hello guys! this is my new series focusing on developing ASP.NET 2.0 applications...
     

    ASP.NET ARTICLES

    - Adding Content to a Static ASP.NET Website
    - Building a Static ASP.NET Website in a Basic...
    - Develop Your First ASP.NET Website with Visu...
    - Run ASP.NET in Windows XP Home with Cassini ...
    - How to Test a Web Application
    - How to Add Code and Validation Controls to a...
    - Working in Source and Split Views to Build a...
    - How to Build a Web Form for a One-Page Web A...
    - How to Develop a One-Page Web Application
    - An ASP.NET Web Application in Action
    - Developing ASP.NET Web Applications
    - An Introduction to ASP.NET Web Programming
    - Introduction to the ADO.NET Entity Framework...
    - Completing an In-Text Advertising System und...
    - Programming an In-Text Advertising System un...





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