0

Hi,
I'm probably missing something really simple or trying too much at once but it's 16:30 on a Friday afternoon and my head is wrecked!!

Basically, I'm trying to build an application that takes out put from a database query as XML and uses XSL to transform it into HTML which is then displayed in a web browser controll on another form.

I thought I break it up into pieces so I decided to just create an XML file and an XSL stylesheet and read this into the web browser control but all I'm getting is <HTML></HTML> !!

Here is my code:

Dim frmViewer As New frmProcessReportViewer 'New Form'

'Create an XMLCompiledTransform object and load the XSL stylesheet.' 
Dim doc As XPathDocument = New XPathDocument("CDCollection.Xml")
Dim Transform As XslCompiledTransform = New XslCompiledTransform
Dim Settings As XsltSettings = New XsltSettings
Settings.EnableScript = True
Transform.Load("CD.xsl", Settings, Nothing)

'need a stream to put it all into'
Dim HTMLStream As New MemoryStream()
Dim StreamWriter As New StreamWriter(HTMLStream, Encoding.Default)

'Place HTML into our StreamWriter'
Transform.Transform(doc, Nothing, StreamWriter)
'Populate the Stream
StreamWriter.Flush()

'Set the WebBrowser.DocumentStream = HTML stream'
'Remember to "AllowNavigation" in Browser otherwise the thing doesn't work.'
frmViewer.WebBrowser1.AllowNavigation = True
frmViewer.WebBrowser1.DocumentStream = HTMLStream

'wait until finished'
Application.DoEvents()

'show as a modal'
frmViewer.ShowDialog()

Anyone tried anything like this before? Our eventual aim to to be able to produce reports in our application form the database without having to use Crystal etc.

Edited by G_Waddell: Comments looking strange

1
Contributor
1
Reply
2
Views
5 Years
Discussion Span
Last Post by G_Waddell
0

OK, Got this working:

Dim frmViewer As New frmProcessReportViewer 'New Form'
Dim StringWriter As New System.IO.StringWriter
Dim XsltArgumentList As New XsltArgumentList
Dim StylesheetPath As String ="MyStylesheet"
Dim doc As XPathDocument = New XPathDocument("CDCollection.Xml")

'Create an XMLCompiledTransform object and load the XSL stylesheet.' 
Dim Transform As XslCompiledTransform = New XslCompiledTransform(true)
Transform.Load(StylesheetPath)
Transform.Transform(doc, XsltArgumentList, StringWriter)
frmViewer.WebBrowser1.DocumentText = StringWriter.ToString
frmViewer.BringToFront()
frmViewer.Height = Me.Height
frmViewer.Width = Me.Width
frmViewer.ShowDialog()

Edited by G_Waddell

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.