Jump to content

ASP.NET and XML/XSLT


kwilliams

Recommended Posts

I'm creating a site that's going to use the ASP.NET Master Page Control to transform XML/XSLT data into the content section of an ASP.NET form. I've already created the basic setup for the site (code below), and some of the content, but I have a few questions/concerns about this method:What I don't like about the Master Page Control so far is the size of the pages. I haven't even put any content on the main section of the page, and it's already 31043 bytes in size. What are some steps that I can take to optimize this site (i.e. caching)? Also, how should I go about creating and processing a form within a transformed page using the Master Page control? Should I use XForms (like http://www.w3schools.com/xforms/default.asp) or dynamic ASP.NET server controls within XML (like http://www.dnzone.com/ShowDetail.asp?NewsId=151)?MASTER PAGE - NavMaster.master

<%@ Master Language="VB" CodeFile="NavMaster.master.vb" Inherits="NavMaster" Debug="True" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server">	<title>Nav MasterPage</title>	<link rel="stylesheet" type="text/css" media="screen" href="~/docs/css/screen.css" /></head><body>	<form id="form1" runat="server">	<div id="wrapper">	<!-- Tab navigation -->		<div id="tabs">			<asp:Menu id="Menu2" runat="server" 				StaticDisplayLevels="1" 				StaticSubMenuIndent="1"				StaticMenuStyle-VerticalPadding="0"				Orientation="Horizontal"				StaticEnableDefaultPopOutImage="False"				StaticMenuItemStyle-HorizontalPadding="0" StaticMenuStyle-HorizontalPadding="0">				<Items>					<asp:MenuItem NavigateUrl="default.aspx" ImageUrl="~/images/gif/tab1_active.gif" />					<asp:MenuItem NavigateUrl="~/aboutus/aboutus.aspx" ImageUrl="~/images/gif/tab2_active.gif" />					<asp:MenuItem NavigateUrl="~/depts/depts.aspx" ImageUrl="~/images/gif/tab3_active.gif" />				</Items>			</asp:Menu>		</div><!-- end tabs -->		<div id="screenleft">			<asp:contentplaceholder 				id="LeftColumn" 				runat="server" />		</div><!-- end screenleft -->		<div id="content">			<!-- dynamic page title -->			<h1><asp:label id="lblPageTitle" runat="server" /></h1>			<br />			<hr class="navyblueline" />			<!-- breadcrumbs -->			<asp:SiteMapPath 				id="SiteMapPath1" 				Runat="Server" />			<br /><br />			<!-- page content -->			<asp:contentplaceholder 				id="ContentColumn" 				runat="server" />		</div><!-- end content -->		<div id="screenright">			<asp:ContentPlaceHolder 				id="RightColumn" 				runat="server">				<asp:Image					ID="Ad1" 					ImageUrl="~/images/gif/ad1.gif"					Runat="Server" />				<br />				<asp:Image					ID="Ad2"  					ImageUrl="~/images/gif/ad2.gif"					Runat="Server" />			</asp:ContentPlaceHolder>		</div><!-- end screenright -->		<div id="screenfooter">			This is the footer section		</div><!-- end screenfooter -->	</div><!-- end wrapper -->	<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />	</form></body></html>

SITEMAP - web.sitemap

<?xml version="1.0" encoding="utf-8" ?><siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0">  <siteMapNode url="~/default.aspx" title="Home" description="Home">	<siteMapNode id="aboutus" url="~/aboutus/aboutus.aspx" title="About Us" description="About Us">	</siteMapNode>	<siteMapNode url="~/depts/depts.aspx" title="Departments" description="Departments">	</siteMapNode>  </siteMapNode></siteMap>

ASP.NET PAGE - default.aspx

<%@ Page Language="VB" MasterPageFile="~/NavMaster.master" AutoEventWireup="false" CodeFile="default.aspx.vb" Inherits="_default" title="Home Page" %><asp:Content ID="Content1" ContentPlaceHolderID="LeftColumn" Runat="Server"><!-- Leftnav buttons go here --><div id="screenleftnav">	<div class="leftheader">About Us</div><!-- end leftheader -->	<ul>		<li><a href="">Button 1</a></li>		<li><a href="">Button 2</a></li>		<li><a href="">Button 3</a></li>		<li><a href="">more...</a></li>	</ul>	<div class="leftheader">Departments</div><!-- end leftheader -->	<ul>		<li><a href="">Button 4</a></li>		<li><a href="">Button 5</a></li>		<li><a href="">Button 6</a></li>		<li><a href="">more...</a></li>	</ul>	<br /></div><!-- end screenleftnav --></asp:Content><asp:Content ID="Content2" ContentPlaceHolderID="ContentColumn" Runat="Server">	This is the main content section. This is where the XML/XSLT transformation will take place.</asp:Content><asp:Content ID="Content3" ContentPlaceHolderID="RightColumn" Runat="Server"><div id="screenright">	This is the right content section.</div><!-- end screenright --></asp:Content>

VB.NET PAGE - default.aspx.vb

Partial Class NavMaster	Inherits System.Web.UI.MasterPage	Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)		lblPageTitle.Text = SiteMap.CurrentNode.Description	End SubEnd Class

RESULTING CODE

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head>	<title>Douglas County, Kansas - Home</title>	<link rel="stylesheet" type="text/css" media="screen" href="docs/css/screen.css" />	<style type="text/css">		.ctl00_Menu1_0 { background-color:white;visibility:hidden;display:none;position:absolute;left:0px;top:0px; }		.ctl00_Menu1_1 { text-decoration:none; }		.ctl00_Menu1_2 {  }		.ctl00_Menu2_0 { background-color:white;visibility:hidden;display:none;position:absolute;left:0px;top:0px; }		.ctl00_Menu2_1 { text-decoration:none; }		.ctl00_Menu2_2 {  }		.ctl00_Menu2_3 {  }		.ctl00_Menu2_4 { padding:0px 0px 0px 0px; }		.ctl00_Menu2_5 { padding:0px 0px 0px 0px; }	</style></head><body>	<form name="aspnetForm" method="post" action="default.aspx" id="aspnetForm">	<div>		<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />		<input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />		<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUJMTgxMjAzNjcwD2QWAmYPZBYCAgMPZBYEAg0PPCsADQIADxYCHgtfIURhdGFCb3VuZGdkDBQrAAIFAzA6MBQrAAIWEh4FVmFsdWUFBEhvbWUeCURhdGFCb3VuZGceCFNlbGVjdGVkZx4EVGV4dAUESG9tZR4LTmF2aWdhdGVVcmwFHC9NYXN0ZXJQYWdlU2l0ZS9kZWZ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		<!--		var theForm = document.forms['aspnetForm'];		if (!theForm) {			theForm = document.aspnetForm;		}		function __doPostBack(eventTarget, eventArgument) {			if (!theForm.onsubmit || (theForm.onsubmit() != false)) {				theForm.__EVENTTARGET.value = eventTarget;	   		 theForm.__EVENTARGUMENT.value = eventArgument;	   		 theForm.submit();   		 }		}		// -->	</script>	<script src="/MasterPageSite/WebResource.axd?d=KKLQ16-PAjSAdMyUqtO2OA2&t=632996128439938112" type="text/javascript"></script>	<script src="/MasterPageSite/WebResource.axd?d=9YVgtnxkl_EC7ZeDVABhuQ2&t=632996128439938112" type="text/javascript"></script>	<div id="wrapper">		<!-- Tab navigation -->				<div id="tabs">			<a href="#ctl00_Menu2_SkipLink"><img alt="Skip Navigation Links" src="/MasterPageSite/WebResource.axd?d=C877-NPBnLlA_xyeDHjJzA2&t=632996128439938112" width="0" height="0" style="border-width:0px;" /></a>			<table id="ctl00_Menu2" class="ctl00_Menu2_5 ctl00_Menu2_2" cellpadding="0" cellspacing="0" border="0">				<tr>					<td onmouseover="Menu_HoverStatic(this)" onmouseout="Menu_Unhover(this)" onkeyup="Menu_Key(this)" id="ctl00_Menu2n0">					<table class="ctl00_Menu2_4" cellpadding="0" cellspacing="0" border="0" width="100%">						<tr>							<td style="white-space:nowrap;"><a class="ctl00_Menu2_1 ctl00_Menu2_3" href="default.aspx"><img src="images/gif/tab1_active.gif" alt="" style="border-style:none;vertical-align:middle;" /></a></td>						</tr>					</table>					</td>					<td style="width:3px;"></td>					<td onmouseover="Menu_HoverStatic(this)" onmouseout="Menu_Unhover(this)" onkeyup="Menu_Key(this)" id="ctl00_Menu2n1">					<table class="ctl00_Menu2_4" cellpadding="0" cellspacing="0" border="0" width="100%">						<tr>							<td style="white-space:nowrap;"><a class="ctl00_Menu2_1 ctl00_Menu2_3" href="aboutus/aboutus.aspx"><img src="images/gif/tab2_active.gif" alt="" style="border-style:none;vertical-align:middle;" /></a></td>						</tr>					</table>					</td>				<td style="width:3px;"></td>				<td onmouseover="Menu_HoverStatic(this)" onmouseout="Menu_Unhover(this)" onkeyup="Menu_Key(this)" id="ctl00_Menu2n2">				<table class="ctl00_Menu2_4" cellpadding="0" cellspacing="0" border="0" width="100%">					<tr>						<td style="white-space:nowrap;"><a class="ctl00_Menu2_1 ctl00_Menu2_3" href="depts/depts.aspx"><img src="images/gif/tab3_active.gif" alt="" style="border-style:none;vertical-align:middle;" /></a></td>					</tr>				</table>				</td>				</tr>			</table>			<a id="ctl00_Menu2_SkipLink"></a>		</div><!-- end tabs -->		<div id="screenleft">						<!-- Leftnav buttons go here -->			<div id="screenleftnav">   				<div class="leftheader">About Us</div><!-- end leftheader -->					<ul>						<li><a href="">Button 1</a></li>						<li><a href="">Button 2</a></li>						<li><a href="">Button 3</a></li>						<li><a href="">more...</a></li>					</ul>				<div class="leftheader">Departments</div><!-- end leftheader -->					<ul>	   					<li><a href="">Button 4</a></li>						<li><a href="">Button 5</a></li>						<li><a href="">Button 6</a></li>						<li><a href="">more...</a></li>					</ul>					<br />			</div><!-- end screenleftnav -->		</div><!-- end screenleft -->		<div id="content">			<!-- dynamic page title -->			<h1><span id="ctl00_lblPageTitle">Home</span></h1>					<br />					<hr class="navyblueline" />					<!-- breadcrumbs -->					<span id="ctl00_SiteMapPath1"><a href="#ctl00_SiteMapPath1_SkipLink"><img alt="Skip Navigation Links" height="0" width="0" src="/MasterPageSite/WebResource.axd?d=C877-NPBnLlA_xyeDHjJzA2&t=632996128439938112" style="border-width:0px;" /></a><span>Home</span><a id="ctl00_SiteMapPath1_SkipLink"></a></span>					<br /><br />				<!-- page content -->				This is the main content section		</div><!-- end content -->		<div id="screenright">				<div id="screenright">		This is the right content section	</div><!-- end screenright -->	<div id="screenfooter">		This is the footer section	</div><!-- end screenfooter -->	</div><!-- end wrapper -->		<div>	<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWDQLLxL+WBgLIi9OIAQLf6Ie+DQLdgvPlDQKO1LKcCwLb4MClDQLggdHzAwLb4MClDQLggdHzAwLb4MClDQLggdHzAwLb4MClDQLggdHzAxNB1ZKW3G9fVbk/8m+rafTOxMR4" /></div><script type="text/javascript">	<!--	var ctl00_Menu1_Data = new Object();	ctl00_Menu1_Data.disappearAfter = 5;	ctl00_Menu1_Data.horizontalOffset = 0;	ctl00_Menu1_Data.verticalOffset = 0;	var ctl00_Menu2_Data = new Object();	ctl00_Menu2_Data.disappearAfter = 500;	ctl00_Menu2_Data.horizontalOffset = 0;	ctl00_Menu2_Data.verticalOffset = 0;	// --></script></form></body></html>

Link to comment
Share on other sites

Can I be honest with you? I REALLY don't like the method you're using... First stop, it seems that you're already using more ASP then you need to. All this ASP code adds a lot of crap in the output.Second, what exactly is the transformation? Bad performance could be due to an XSLT file filled with just as much crap.Third, you're not using that much XSLT. Most of the stuff was done in ASP, which kind of kills one of the major points of XSLT - to be portable.As for forms... XForms are the better way, but they are not supported in any browser today without plug-ins, and requiring users to download plug-ins is just not very profitable. Perhaps the JavaScript implementation FormFaces is the way today if you want XForms.If you find ASP's form controls more efficient... go ahead. Until XForms are supported natively by all of the major browsers, there really is not a "best practice" for forms. Not for form sets anyway.

Link to comment
Share on other sites

Can I be honest with you? I REALLY don't like the method you're using... First stop, it seems that you're already using more ASP then you need to. All this ASP code adds a lot of crap in the output.Second, what exactly is the transformation? Bad performance could be due to an XSLT file filled with just as much crap.Third, you're not using that much XSLT. Most of the stuff was done in ASP, which kind of kills one of the major points of XSLT - to be portable.As for forms... XForms are the better way, but they are not supported in any browser today without plug-ins, and requiring users to download plug-ins is just not very profitable. Perhaps the JavaScript implementation FormFaces is the way today if you want XForms.If you find ASP's form controls more efficient... go ahead. Until XForms are supported natively by all of the major browsers, there really is not a "best practice" for forms. Not for form sets anyway.
Thanks for your honesty. I do appreciate it. I like the centrality of the Master Page control, but I find that it's built-in functions, although handy, are not easily flexible.I had created another solution that used XML/XSLT mostly with just a transformation on the ASP.NET page. But the problem I've run into with that solution is how to process input forms. I'm using XSLT on-the-server as opposed to on-the-client, so I thought that this solution would avoid the browser support issues. I like the way XForms works, and if I could use it with my XSLT on-the-server approach, that would be great. If you could let me know how I would go about processing that data once it's been entered and validated, that would be great also.If there is no way for me to use XForms, even with the XSLT on-the-server, then I'd also appreciate some other options being put forth by you or others. Thanks for any help.
Link to comment
Share on other sites

What I don't like about the Master Page Control so far is the size of the pages. I haven't even put any content on the main section of the page, and it's already 31043 bytes in size. What are some steps that I can take to optimize this site (i.e. caching)?
I haven't begun playing around with MasterPages yet so I can't be of much help there. However, some of the page size is because of the ViewState. You've got a number of controls in the MasterPage that have runat="server". When a control is run at server, a ViewState is saved for that control so that when the page is posted back to the server, the server can remember what the data in the control was. Your current ViewState (as per your example page) is:
/wEPDwUJMTgxMjAzNjcwD2QWAmYPZBYCAgMPZBYEAg0PPCsADQIADxYCHgtfIURhdGFCb3VuZGdkDBQrAAIFAzA6MBQrAAIWEh4FVmFsdWUFBEhvbWUeCURhdGFCb3VuZGceCFNlbGVjdGVkZx4EVGV4dAUESG9tZR4LTmF2aWdhdGVVcmwFHC9NYXN0ZXJQYWdlU2l0ZS9kZWZhdWx0LmFzcHgeB0VuYWJsZWRnHgpTZWxlY3RhYmxlZx4HVG9vbFRpcAUESG9tZR4IRGF0YVBhdGgFHC9tYXN0ZXJwYWdlc2l0ZS9kZWZhdWx0LmFzcHgUKwAHBRcwOjAsMDoxLDA6MiwwOjMsMDo0LDA6NRQrAAIWEB8EBRBBYm91dCB0aGUgQ291bnR5HwEFEEFib3V0IHRoZSBDb3VudHkfBQUkL01hc3RlclBhZ2VTaXRlL2Fib3V0ZGMvYWJvdXRkYy5hc3B4HwgFEEFib3V0IHRoZSBDb3VudHkfBmcfB2cfCQUkL21hc3RlcnBhZ2VzaXRlL2Fib3V0ZGMvYWJvdXRkYy5hc3B4HwJnFCsAAgUDMDowFCsAAhYQHwQFCFByb2R1Y3RzHwEFCFByb2R1Y3RzHwUFJS9NYXN0ZXJQYWdlU2l0ZS9hYm91dGRjL3Byb2R1Y3RzLmF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bG9jYWxfZ292dC5hc3B4HwJnZBQrAAIWEB8EBQ9PbmxpbmUgU2VydmljZXMfAQUPT25saW5lIFNlcnZpY2VzHwUFNC9NYXN0ZXJQYWdlU2l0ZS9vbmxpbmVfc2VydmljZXMvb25saW5lX3NlcnZpY2VzLmFzcHgfCAUPT25saW5lIFNlcnZpY2VzHwZnHwdnHwkFNC9tYXN0ZXJwYWdlc2l0ZS9vbmxpbmVfc2VydmljZXMvb25saW5lX3NlcnZpY2VzLmFzcHgfAmcUKwACBQMwOjAUKwACFhAfBAUHZUFsZXJ0cx8BBQdlQWxlcnRzHwUFLC9NYXN0ZXJQYWdlU2l0ZS9vbmxpbmVfc2VydmljZXMvZWFsZXJ0cy5hc3B4HwgFB2VBbGVydHMfBmcfB2cfCQUsL21hc3RlcnBhZ2VzaXRlL29ubGluZV9zZXJ2aWNlcy9lYWxlcnRzLmFzcHgfAmdkZAITDw8WAh8EBQRIb21lZGQYAQULY3RsMDAkTWVudTEPD2QFBEhvbWVkXp6pLJa+v0aDYZ0Mw0FTTM5KeMs=

You could help get rid of that by setting EnableViewState="false" for the controls that are on pages which you will not be posting back to the server.An approach that I take with a lot of sites is to use webcontrols (ascx files). If you build a web control for your navigation, you can include that webcontrol on any page that uses the navigation. Further, if those web controls are static HTML, (as far as I know) the server will compile those controls and serve them from cache rather than dynamically building them each time a page loads. This could help improve processing time on the server.EDIT: You can also improve file size (i.e. make it smaller) by getting rid of all the white space in your page. Rather than indenting each line with spaces or tabs, start each line on the left margin. Sure, it's a little bit harder to read the code, but each of those whitespace characters takes up a single byte.

					<ul>						<li><a href="">Button 1</a></li>						<li><a href="">Button 2</a></li>						<li><a href="">Button 3</a></li>						<li><a href="">more...</a></li>					</ul>

That code has 136 spaces used to indent the HTML. Each of those spaces is a single byte meaning that the following code is 136 bytes shorter:

<ul><li><a href="">Button 1</a></li><li><a href="">Button 2</a></li><li><a href="">Button 3</a></li><li><a href="">more...</a></li></ul>

Taken over an entire page, you can remove 4KB on a small page to 30KB on a larger one.

Link to comment
Share on other sites

Hi jesh,I tried your suggestion, like this:FROM:<%@ Page Language="VB" MasterPageFile="~/NavMaster.master" AutoEventWireup="false" CodeFile="default.aspx.vb" Inherits="_default" title="Home" %>TO:<%@ Page Language="VB" MasterPageFile="~/NavMaster.master" AutoEventWireup="false" CodeFile="default.aspx.vb" Inherits="_default" title="Home" EnableViewState="false" %>...and it did change the page's size from 30890 bytes to 28690 bytes. But when I went to view the source code of the page, I still saw the View State, like this:

...<body>	<form name="aspnetForm" method="post" action="default.aspx" id="aspnetForm"><div><input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" /><input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" /><input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUJMTgxMjAzNjcwZBgBBQtjdGwwMCRNZW51MQ8PZAUESG9tZWSjlkpjfcleQxf6aiJ4WDd9HnXDvA==" /></div>...

Am I missing something?

Link to comment
Share on other sites

I wouldn't suggest setting the EnableViewState to false globally for all of your pages unless you have a different MasterPage for pages which need to be posted back to the server. Rather, I would suggest setting the EnableViewState="false" for each individual control.Even with ViewState turned off for the entire page or for every control, I think .NET still puts that token ViewState on the page. I don't know the answer to why it does that.

Link to comment
Share on other sites

The fact that you are using XSLT on the server, rather then the client actually gives you a lot of advantages, and form handling is not an exclusion.I would however suggest that you send forms to different ASP.NET files, unless the form is purely controlling the appearance of the page. This would increase:

  • Flexibility - Scince you'll be able to adjust the form controls without worring that an error in them would cause the other parts of the site to fail.
  • Performance - Scince there won't be checks on whether the current query is from a form.
  • Readability - Scince you'll only be looking at the code you need to edit.

In a true XForm, you would have to check the raw post data. I don't know how to do that in ASP.NET though. In PHP it's with the $HTTP_RAW_POST_DATA variable.As for how to do it by using FormFaces... I have no idea. I haven't even tryed it out yet. I only tryed a real XForm and I used XSmiles as a browser, scince it's the one of the few user agents with XForms support.By the way, if you use XSLT to form the (X)HTML of the complete page, you can use

<xsl:output indent="no"/>

to remove all extra whitespace from your output.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...