Groups | Blog | Home
all groups > dotnet xml > february 2005 >

dotnet xml : Extra HTML In Response.OutputStream from ASP.Net xslDoc.Transform


Todd
2/17/2005 5:59:01 AM

Hello Folks!

Using http://support.microsoft.com/default.aspx?scid=kb;en-us;320847 as
a reference, I am trying to pipe the results of an XSL Transformation
directly out of a WebApp Default.aspx. The code is as follows;

------------------------------------------
Private Sub Page_Load(...) Handles MyBase.Load
'Put user code to initialize the page here
Dim xslDoc As New XslTransform
Dim xmlDoc As New XPathDocument(Me.Page.MapPath("cdcatalog.xml"))
Dim xmlRes As XmlResolver
xslDoc.Load(Me.Page.MapPath("cdcatalog.xsl"))
xslDoc.Transform(xmlDoc, Nothing, Response.OutputStream, xmlRes)
End Sub
------------------------------------------

This works with the exception of additional html at the end of the page
as noticed by "View Source". The shortened output is as follows

------------------------------------------
<html>
<body>
<h2>My CD Collection</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th align="left">Title</th>
<th align="left">Artist</th>
</tr>
<tr>
<td>Empire Burlesque</td>
<td>Bob Dylan</td>
</tr>
*************************************
*** This is all expecte output ***
*************************************
<tr>
<td>Unchain my heart</td>
<td>Joe Cocker</td>
</tr>
</table>
</body>
</html>
*************************************
*** The unexpected output follows ***
*************************************
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>xml2html</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<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">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form name="Form1" method="post" action="xml2html.aspx" id="Form1">
<input type="hidden" name="__VIEWSTATE"
value="dDwtNjU0MzcyMTk1Ozs+xZpchddE2teruVaYH4BmcjbIhbs=" />

</form>
</body>
</HTML>
------------------------------------------

I have tried Stream.Position, Stream.Flush and Stream.EndWrite but with
no success.

***** Question: Is there a way to omit the extra HTML?
--

Best Regards
Todd Cartner
2/17/2005 11:26:35 AM

Thank you So Much!

That works just great. I was thinking that the <form> tag was a
required part of Web Apps but that must only be for the traditional posting
of data. Anyway, thank you again and have a wonderful day.

Sincerely
Todd

[quoted text, click to view]

Samu Lang
2/17/2005 3:48:54 PM
Hello Todd,

This extra HTML is coming from the .aspx file hosting your webform. In your
case this file is only a placeholder, something with the appropriate
extension to drive the request to your class. Just remove the HTML code from
your .aspx file.

Be sure to leave the <%Page directive, otherwise your page won't be
associated with your .vb code-behind file and your form class.

Cheers,
Samu

AddThis Social Bookmark Button