473,237 Members | 1,070 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,237 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"
AutoEventWireup="false"
Codebehind="QuestionnairePage.aspx.vb"
Inherits="Battelle.QuestionnairePage" enableViewState="True"
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Form Document</TITLE>
<meta content="Microsoft Visual Studio .NET 7.1"
name="GENERATOR">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET
7.1">
<meta name="vs_defaultClientScript"
content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
<link rel="stylesheet"
href="../Styles/QuestionStyle.css">
<script type="text/javascript" language="JavaScript"
src="../Config/Code/XMLactions.js" />
</HEAD>
<body MS_POSITIONING="GridLayout"
onload="formatUI(document.form1);">
<FORM id="form1" method="post" runat="server">
<DIV class="xml_Div" id="xmlData"
style="WIDTH: 100%; POSITION: absolute; HEIGHT: 100%"
runat="server"
MS_POSITIONING="GridLayout">
</DIV>
</FORM>
</body>
</HTML>
----------------------------------------------------------------------

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
System.Web.UI.HtmlControls.HtmlInputHidden
Protected WithEvents xsltSourceBox As
System.Web.UI.HtmlControls.HtmlInputHidden
Protected WithEvents xmlData As
System.Web.UI.HtmlControls.HtmlGenericControl
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 =
CInt(Trim(Request.QueryString("DocID")))
Dim DocVersion As Double =
CDbl(Trim(Request.QueryString("Ver")))
Dim EmployeeID As String =
UCase(Trim(Request.QueryString("EmpID")))
Dim xDoc As New XmlDocument
Dim xslt As New XslTransform
If EmployeeID.Length = 0 Then
'get data
retrieveMasterDocument(xDoc, xslt, DocID, DocVersion)
Else
'get data
retrieveUserDocument(xDoc, xslt, DocID, DocVersion,
EmployeeID)
End If
'display xml
displayXML(xDoc, xslt)
End If
End Sub

Private Sub displayXML(ByRef xDoc As XmlDocument, ByRef xslt As
XslTransform)
Dim resolver As XmlUrlResolver = New XmlUrlResolver
resolver.Credentials =
System.Net.CredentialCache.DefaultCredentials
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
StreamReader(xmlStream).ReadToEnd()
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)
Try
If err.Message.Length > 0 Then
Response.StatusDescription = err.Message
Response.Redirect("../Screens/RunTimeError.aspx")
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
Double)
Dim _xsltPath As String = "../Styles/Question.xslt"
xslt.Load(context.Server.MapPath(_xsltPath))
Dim data As New
DataRetrieval(ConfigurationSettings.AppSettings("A nsweredQuestions_LOCAL"))
xDoc = data.selectMasterDocument(docID, version, _err)
pageError(_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"
xslt.Load(context.Server.MapPath(_xsltPath))
Dim data As New
DataRetrieval(ConfigurationSettings.AppSettings("A nsweredQuestions_LOCAL"))
xDoc = data.selectAnsweredDocument(emplID, docID, version,
_err)
pageError(_err)
End Sub
End Class
----------------------------------------------------------------------

The sub displayXML tries to use a stream object to capture the
transformed
xml and then convert that stream into a string then into the
..innerHTML.
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 2315

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Darren Davison | last post by:
given the following DOM snippet; <root> <sub1 foo="4">testing</sub1> <sub1 foo="0">hello</sub1> <sub1 foo="0">world</sub1> <sub1>hello again</sub1> </root> I need to transform with XSL to...
0
by: Jay Allard | last post by:
Hello I posted this in the vb.net group on the 2/25/2004, but didn't get any response. Here's attempt 2. Does anyone know of a more appropriate place to post this? One new piece of...
7
by: Harolds | last post by:
The code below worked in VS 2003 & dotnet framework 1.1 but now in VS 2005 the pmID is evaluated to "" instead of what the value is set to: .... xmlItems.Document = pmXML // Add the pmID...
3
by: thomas.porschberg | last post by:
Hi, I want to read records from a database and export it in an arbitrary format. My idea was to feed a class with a String array fetched from the database and let this class fire SAX events as...
1
by: Nick | last post by:
I am working on a website for a client and one of their requirements was to have a mailing list. I decided to XSLT to transform "templates" to HTML so that editing was very easy and less time...
3
by: shaun roe | last post by:
mild rant follows Working now for a couple of years with xslt and now xslt 2.0, does anyone else get the impression that xslt 2.0 somehow missed the point? Yes its got a fancy new data model...
12
by: Chris | last post by:
Hi, Just wondering if anyone out there knows if it is possible to convert a CSV to xml using XSLT? I've seen a lot of examples of xml to CSV, but is it possible to go back the other way? I...
4
by: Andrew Jackson | last post by:
I am writing a newsgroup client. I have the protocol figured out. But I get slow transfer speeds off any of the network objects read the data from For example one of the commands for a news...
2
by: Jonny B | last post by:
Hi all, I'm working on an a clientside xslt using jscript that passes a parameter to the xsl. I've got it working no problem in IE but cant get it to work in Mozilla. Can anyone help? This is...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.