What does this mean(web site content)

T

Tony

Hello!

I have run into something that I don't really understand. I hope somebody here understand this.
"Some web sites also use XML entirely for their content, where traditionally, HTML would have been used.
This XML can then be transformed into HTML via XSLT or displayed directly in browsers via CSS.
In fact, the web servers can even determine dynamically what kind of browsers is rertieving the information, and
then decide what to do. For example transform the XML into HTML for older browsers, and just send the XML straight to the client for newer browses, reducing the load on the server."

What I don't understand here is this
For example transform the XML into HTML for older browsers, and just send the XML straight to the client for newer browses, reducing the load on the server.

As far as I know when running an asp.net application will all be information be sent as HTML to the client and not as XML but
I'm I wrong here because of the above text.

//Tony
 
J

Jason Keats

Tony said:
Hello!
I have run into something that I don't really understand. I hope
somebody here understand this.
"Some web sites also use XML entirely for their content, where
traditionally, HTML would have been used.
This XML can then be transformed into HTML via XSLT or displayed
directly in browsers via CSS.
In fact, the web servers can even determine dynamically what kind of
browsers is rertieving the information, and
then decide what to do. For example transform the XML into HTML for
older browsers, and just send the XML straight to the client for newer
browses, reducing the load on the server."
What I don't understand here is this
For example transform the XML into HTML for older browsers, and just
send the XML straight to the client for newer browses, reducing the load
on the server.
As far as I know when running an asp.net application will all be
information be sent as HTML to the client and not as XML but
I'm I wrong here because of the above text.
//Tony

There are many ways to create an ASP.NET application. You're right that
most return HTML, but you could have all your .aspx pages containing a
single line, such as:

<%@ Page Language="cs" AutoEventWireup="false" Codebehind="bar.aspx.cs"
Inherits="foo.bar"%>

and then your Page_Load just has to do a Response.Write(something).

You can "Write" anything you like. It could be plain text, HTML, XML,
JSON... It's up to you what is returned. Remember, it may not even be a
browser that is "calling" the (aspx) web page - it could be a desktop
application doing an HttpRequest.

If you were just doing something like the above, however, it would
probably be more efficient to use a HttpHandler.
 
A

Arne Vajhøj

I have run into something that I don't really understand. I hope
somebody here understand this.
"Some web sites also use XML entirely for their content, where
traditionally, HTML would have been used.
This XML can then be transformed into HTML via XSLT or displayed
directly in browsers via CSS.
In fact, the web servers can even determine dynamically what kind of
browsers is rertieving the information, and
then decide what to do. For example transform the XML into HTML for
older browsers, and just send the XML straight to the client for newer
browses, reducing the load on the server."
What I don't understand here is this
For example transform the XML into HTML for older browsers, and just
send the XML straight to the client for newer browses, reducing the load
on the server.
As far as I know when running an asp.net application will all be
information be sent as HTML to the client and not as XML but
I'm I wrong here because of the above text.

Let me illustrate with an example.

First let us do it in HTML.

html.aspx:

<script language="C#" runat="server">
void Page_Load(Object sender, EventArgs e)
{
lbl.Text = "It works fine!";
}
</script>
<html>
<head>
<title>HTML version</title>
</head>
<body>
<form runat=server>
<asp:label id="lbl" runat="server"/>
</form>
</body>
</html>

Hopefully no surprises in that.

Now let us try to do it in XML and XSL with style sheet
processing being don client side.

xml.ashx:

<%@ WebHandler Language="C#" Class="E.XmlGen" %>

using System;
using System.Web;

namespace E
{
public class XmlGen : IHttpHandler
{
public void ProcessRequest (HttpContext ctx) {
ctx.Response.ContentType = "text/xml";
ctx.Response.Write("<?xml-stylesheet type='text/xsl'
href='page.xsl'?>");
ctx.Response.Write("<data>It works fine!</data>");
}
public bool IsReusable
{
get { return true; }
}
}
}


page.xsl:

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="/">
<html>
<head>
<title>XML version</title>
</head>
<body>
<xsl:value-of select="data"/>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

Is the XML version better than the HTML version? In this case
I would say no, but there could be better cases for using XML.

The XML and style sheet processing client side was a bit hot
10 years ago - it is my impression that it is rarely used today.

So I don't think you should spend too much time on it.

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top