Wrox Programmer Forums
|
VB.NET General VB.NET discussions for issues that don't fall into other VB.NET forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 4th, 2003, 11:59 AM
Registered User
 
Join Date: Jul 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default XSL Transformations

It seems to me that the most practical use for a transformation is to transform an XML string that has been assembled from various data calls. This XML string would be the data for a web page or other user interface. There doesn't seem to be a lot of good examples out there of this. SO I put one together and would like some feedback from anyone that would like to improve upon it. Here is the code:
Public Class XForm
    Public Function ConvertXmlToHtml( _
        ByVal XmlString As String, _
        ByVal XslFileName As String _
    ) As String

        Dim utf8encoder As System.Text.UTF8Encoding = New System.Text.UTF8Encoding
        Dim inputInBytes() As Byte = utf8encoder.GetBytes(XmlString)
        Dim ms As New System.IO.MemoryStream(inputInBytes)
        Dim sr As System.IO.StreamReader
        Dim xslt As New System.Xml.Xsl.XslTransform
        Dim xpn As System.Xml.XPath.XPathNavigator
        Dim xpd As System.Xml.XPath.XPathDocument
        Dim rs As String

        xpd = New System.Xml.XPath.XPathDocument(ms)
        ms.Close()
        ms = New System.IO.MemoryStream
        xslt.Load(XslFileName)
        xslt.Transform(xpd, Nothing, ms, Nothing)
        xslt = Nothing
        xpn = Nothing
        xpd = Nothing

        sr = New System.IO.StreamReader(ms)
        sr.BaseStream.Seek(0, System.IO.SeekOrigin.Begin)
        rs = sr.ReadToEnd()
        ms.Close()
        sr.Close()
        ms = Nothing
        sr = Nothing
        Return rs
    End Function
End Class





Similar Threads
Thread Thread Starter Forum Replies Last Post
sequential transformations alexan XSLT 0 July 24th, 2008 11:59 PM
Pass link values as xsl:parameter to php5 then xsl pauljr8 XSLT 1 July 2nd, 2007 10:32 PM
XSLProcessor asynchronous transformations Vx BOOK: Professional Ajax ISBN: 978-0-471-77778-6 1 September 5th, 2006 12:41 PM
DTS transformations Amorous SQL Server DTS 0 January 18th, 2006 04:54 PM
XSL Transform with xsl string NOT xsl file skin XSLT 0 June 16th, 2003 07:30 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.