MS SQL Server
  Home arrow MS SQL Server arrow Page 9 - XML and the SQL 2000 Server, Part 4: Intro...
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  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Moblin 
JMSL Numerical Library 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
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? 
MS SQL SERVER

XML and the SQL 2000 Server, Part 4: Introducing SqlXml 3.0
By: Jayaram Krishnaswamy
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 2 stars2 stars2 stars2 stars2 stars / 11
    2005-06-01

    Table of Contents:
  • XML and the SQL 2000 Server, Part 4: Introducing SqlXml 3.0
  • XML data using Dataset
  • Enter SQLXML 3.0
  • Exploring the SqlXmlCommand Class
  • SqlXmlCommand's RootTag Property
  • SqlXmlCommand's NameSpace Property
  • SqlXmlCommand's ExecuteXMLReader
  • Using CommandType Template
  • Using the BasePath and XSLPath properties

  • 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


    XML and the SQL 2000 Server, Part 4: Introducing SqlXml 3.0 - Using the BasePath and XSLPath properties


    (Page 9 of 9 )

    XML data although eminently suited for transport does not have the look of HTML. This is where XSL steps in to transform XML into HTML that is universally liked as a display format. However, XSL is for transformations of not only HTML but to other formats as well. SqlXmlCommand objects properties can help transofrm the XML into presentable HTML format as shown with the following code. You may need a little backgorund on XSL and the recommended site is http://www.w3c.org/, the Mecca for everything about XML.

    This code does several things. It uses a stored template file and executes the command and through its XslPath property it references a stored XSL style sheet to be included into the returned results. The resulting document is stored as an HTML file in the chosen location. The XML file follows the code in the XSL file provided to format the HTML. A truncated FullName.htm is shown in the screen shot.

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As 
    System.EventArgs)
    Handles MyBase.Load 'Put user code to initialize the page here If Not IsPostBack Then Dim sxcmd As New SqlXmlCommand("Integrated Security=SSPI;
    Packet Size=4096;Data Source=XPHTEK;
    Tag with column collation when possible=False;
    Initial Catalog=pubs;Use Procedure for Prepare=1;
    Auto Translate= True;Persist SecurityInfo=False;
    Provider='SQLOLEDB.1';Workstation ID=XPHTEK;Use Encryption for
    Data=False") sxcmd.CommandType = SqlXmlCommandType.TemplateFile sxcmd.RootTag = "author" sxcmd.CommandText = Server.MapPath("Tplauthors.xml") Response.Write(sxcmd.CommandText) sxcmd.XslPath = Server.MapPath("authors.xsl") Dim strmResults As New FileStream
    ("C:\FullName.htm", FileMode.Append) sxcmd.ExecuteToStream(strmResults) End If End Sub
    authors.xsl file
    <?xml version='1.0'?><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    version="1.0"> <xsl:template match="/"><html><body><h2>Full Name of Authors</h2><table border="1.0" bgcolor="gold"><tr><td>Full Name</td></tr><xsl:for-each select="root/authors"><tr><td><xsl:value-of select='@fullName'></xsl:value-of></td></tr></xsl:for-each></table></body></html></xsl:template></xsl:stylesheet>

    Conclusions

    This tutorial, 4th part in this series, is focussed on the SQLXML3.0 enhancements that make working with XML a lot easier through its support by means of several properties and methods. Only the data access part has been touched in this tutorial and of course it is also possible to make changes to the database by using some of the other items left out, notably the UpdatGram and DiffGram. These will be discussed in a forth coming tutorial.

    The codes shown in this tutorial were tested on Visual Studio .NET 2003 on XP Professional platform with the backend server running in the same box as the IIS 5.0. If the server references are made correctly in the connection string, cutting and pasting the code should work. The imports should include the System.IO and Microsoft.Data.SqlXml. However, when files are written to hard disk, permissions should be present and this is also true for database access and while executing stored procedures.


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

     

    MS SQL SERVER ARTICLES

    - Completing the Introduction to Transact-SQL
    - A Brief Introduction to Transact-SQL
    - Lookups and Blocking Bad Data
    - Field Validation Rules for Blocking Bad Data
    - Using Masks to Block Bad Data
    - Blocking Bad Data
    - Using @@ROWCOUNT and TABLE Variables for Dat...
    - How to Use Variables, IF and CASE in Databas...
    - Creating Important Aspects of Notification S...
    - Working wth Variables in Database Interactio...
    - Delving Deeper into Notification Services
    - Notification Services
    - Building a Multi-table Report with SQL 2005 ...
    - A Secure Way of Building Connection Strings
    - Transferring a Database Using the SSIS Desig...





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway