471,594 Members | 1,880 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,594 software developers and data experts.

xslt.transfer function, I need it return a string of sorts

I have done my best to answer this question but can not find the
proper set of commands. I would like
to transform an xml file (in code behind) and display its output in a
specific html tag, such as a div with
a runat=server. I can somewhat do this if I create a server control
and include the control within the html
div tag but this method (borrowed from ASP.NET Website Programming by
Wrox press thanks guys) does not give me
the full control over the xml.

In my app I need to load different xml docs (depended on
selections from a previous screen). I have
the following html code:
<%@ Page Language="vb"
Inherits="Battelle.QuestionnairePage" enableViewState="True"
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<TITLE>Form Document</TITLE>
<meta content="Microsoft Visual Studio .NET 7.1"
<meta name="CODE_LANGUAGE" content="Visual Basic .NET
<meta name="vs_defaultClientScript"
<meta name="vs_targetSchema"
<link rel="stylesheet"
<script type="text/javascript" language="JavaScript"
src="../Config/Code/XMLactions.js" />
<body MS_POSITIONING="GridLayout"
<FORM id="form1" method="post" runat="server">
<DIV class="xml_Div" id="xmlData"
style="WIDTH: 100%; POSITION: absolute; HEIGHT: 100%"

The folling vb.NET code:
Imports System.IO
Imports System.Text
Imports System.Xml
Imports System.Xml.Xsl
Imports System.Xml.XPath
Public Class QuestionnairePage
Inherits System.Web.UI.Page
Protected WithEvents xmlSourceBox As
Protected WithEvents xsltSourceBox As
Protected WithEvents xmlData As
Dim _err As Exception
#Region " Web Form Designer Generated Code "
--code takenout to save space.
#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If (Not IsPostBack) Then
Dim DocID As Integer =
Dim DocVersion As Double =
Dim EmployeeID As String =
Dim xDoc As New XmlDocument
Dim xslt As New XslTransform
If EmployeeID.Length = 0 Then
'get data
retrieveMasterDocument(xDoc, xslt, DocID, DocVersion)
'get data
retrieveUserDocument(xDoc, xslt, DocID, DocVersion,
End If
'display xml
displayXML(xDoc, xslt)
End If
End Sub

Private Sub displayXML(ByRef xDoc As XmlDocument, ByRef xslt As
Dim resolver As XmlUrlResolver = New XmlUrlResolver
resolver.Credentials =
Dim xmlStream As Stream

' Transform the file.
'Get error here because xmlStream is Nothing.
xslt.Transform(xDoc, Nothing, xmlStream, resolver)
Dim htmlText As String = New
xmlData.InnerHtml = htmlText

'This replaces all html on the page.
'xslt.Transform(xDoc, Nothing, Page.Response.Output, Nothing)

End Sub

Private Sub pageError(ByRef err As Exception)
If err.Message.Length > 0 Then
Response.StatusDescription = err.Message
End If
Catch ex As Exception

End Try
End Sub

Private Sub retrieveMasterDocument(ByRef xDoc As XmlDocument,
ByRef xslt As XslTransform, ByVal docID As Integer, ByVal version As
Dim _xsltPath As String = "../Styles/Question.xslt"
Dim data As New
DataRetrieval(ConfigurationSettings.AppSettings("A nsweredQuestions_LOCAL"))
xDoc = data.selectMasterDocument(docID, version, _err)
End Sub

Private Sub retrieveUserDocument(ByRef xDoc As XmlDocument, _
ByRef xslt As XslTransform, _
ByVal docID As Integer, _
ByVal version As Double, _
ByVal emplID As String)
Dim _xsltPath As String = "../Styles/Question.xslt"
Dim data As New
DataRetrieval(ConfigurationSettings.AppSettings("A nsweredQuestions_LOCAL"))
xDoc = data.selectAnsweredDocument(emplID, docID, version,
End Sub
End Class

The sub displayXML tries to use a stream object to capture the
xml and then convert that stream into a string then into the
I am getting an error message because the stream object is Nothing.
My take is that
I should not be using the stream this way. Anyone have any ideas of
how to
transform an xml into a string so it can be placed surgically into the
html page?

Nov 12 '05 #1
0 2224

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Darren Davison | last post: by
7 posts views Thread by Harolds | last post: by
3 posts views Thread by thomas.porschberg | last post: by
1 post views Thread by Nick | last post: by
3 posts views Thread by shaun roe | last post: by
12 posts views Thread by Chris | last post: by
2 posts views Thread by Jonny B | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by Anwar ali | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.